Results 1 to 4 of 4

Thread: !

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Mar:2018
    Location: Bulgaria
    Posts: 2

    Question !

    , , . :
    ' , , . , '' 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();
    }
    !

  2. #2
    Registered User
    Join Date: Oct:2006
    Location: Plovdiv
    Posts: 895
    5 ( ). 1 10 do while.
    - if.
    .

    ?

  3. #3
    Registered User
    Join Date: Mar:2018
    Location: Bulgaria
    Posts: 2
    , , . , , ..., '++' , , ...!

  4. #4
    Mire-x
    Join Date: Apr:2005
    Location: Sofia
    Posts: 763
    - ( ) . - , - .
    (10b) || !(10b)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |