#include <stdio.h>
#include <string.h>
int main(){
int i, numMovies, rating, favRating, leastRating;
char movieName[40], favorite[40], least[40];
favRating = 0;
leastRating = 10;
do {
printf("How many movies have you seen this year? ");
scanf(" %d", &numMovies);
if (numMovies < 1) {
printf("No movies! How can you rank them?/n");
printf("Try again!/n/n");
}
} while (numMovies < 1);
for (i = 1; i <= numMovies; i++)
{
printf("/nWhat was the name of the movie? ");
printf("(1-word titles only!) ");
scanf(" %s", movieName);
printf("On a scale of 1 to 10, what would ");
printf("you rate it? ");
scanf(" %d", &rating);
if (rating > favRating){
strcpy(favorite, movieName);
favRating = rating;
}
if (rating < leastRating){
strcpy(least, movieName);
leastRating = rating;
}
}
printf("/nYour Favorite Movie was %s./n", favorite);
printf("/nYour Least-favorite Movie was %s./n", least);
return 0;
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266516.html