Results 1 to 4 of 4
Thread: !
Hybrid View
-
2nd March 2018 02:01 #1Registered User
Join Date: Mar:2018
Location: Bulgaria
Posts: 2
!
, , . :
' , , . , '' 5 , , 1 10. , , . , - , -. , - . , - . , .. .. , , .. .. -.. :
!Code:/* Obtain the Public's Opinion on topics */ #include <stdio.h> #define ISSUES 5 #define RATINGS 10 // function prototypes void recordResponse (int i, int response); //^^implement this void highestRatings (); //void lowestRatings (); //^^implement this void displayResults(); int responses[ISSUES][RATINGS]; // Two-dimensional array of poll-ratings const char *topics[ISSUES] = {"Topic 1", "Topic 2", "Topic 3", "Topic 4", "Topic 5"}; // array of opinion topics int main (void) { int response; // the user's responses // Administer the poll. do { // ^^ Ask the user to rate the 5 topics in the topics array (for loop) remeber to check for for valid entries and record the response. printf("%s", "Enter 1 to stop or 0 to allow a new person to rate the issues again: "); // Ask if the user wants to stop scanf("%d", &response); // get the user's response } while(response != 1); displayResults(); } // Records the user's response to a topic located at index i void recordResponse(int issue, int rating) { //^^ record the responses by updating the responses array } // end recordResponse // get the highest rated topic (highest point total) void highestRatings(void) { int highRating = 0; int highTopic = 0; for (unsigned int i = 0; i < ISSUES ; i++) { int topicRating = 0; for (unsigned int j = 0; j < RATINGS ; j++) { topicRating += responses[i][j]*(j+1); } if (highRating < topicRating) { highRating = topicRating; highTopic = i;// index of the highest rated topic } } printf("The highest rated topic was %s with a total rating of %d\n", topics[highTopic], highRating); } // get the lowest rated topic (lowest point total) void lowestRatings(void) { //^^ implement this } printf("The lowest rated topic was %s with a total rating of %d\n", topics[lowTopic], lowRating); } // Output in tabular form the number of ratings per issue void displayResults() { // Output table header printf("%20s", "Topic"); for (unsigned int i = 1; i <= RATINGS; ++i) { printf("%4d", i); } // Output the highest and lowest ratings for this poll highestRatings(); lowestRatings(); }
-
2nd March 2018 09:44 #2Registered User
Join Date: Oct:2006
Location: Plovdiv
Posts: 895
5 ( ). 1 10 do while.
- if.
.
?
-
6th March 2018 19:23 #3Registered User
Join Date: Mar:2018
Location: Bulgaria
Posts: 2
, , . , , ..., '++' , , ...!
-
7th March 2018 06:30 #4Mire-x
Join Date: Apr:2005
Location: Sofia
Posts: 763
- ( ) . - , - .
(10b) || !(10b)




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in