我不明白爲什麼if和if循環不起作用。我也不明白,爲什麼我無法從過去B的程序(而不是IRL等級)獲得價值等級。邏輯不會流下來。 所有這個程序的目的是做三個輸入等級int(0 -100),並根據設置的「>或<」給出等級。但他們不爲我工作。我能做些什麼來獲得如果其他工作? 謝謝。C如果其他循環不起作用
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdbool.h>
// Functions
void readScores(int* test1, int* test2, int* test3);
int determineAverage(int test1, int test2, int test3);
void print(int test3, int average, int test2_test3Av);
int avgtest2test3(int test2, int test3);
int main(void)
{
int test1;
int test2;
int test3;
int average;
int test2_test3Av;
readScores(&test1, &test2, &test3); // takes input
average = determineAverage(test1, test2, test3); // finds average
test2_test3Av = avgtest2test3(test2, test3); // gets average of test one and two
print(test3, average, test2_test3Av); // Prints grade resluts
return 0;
}
void readScores(int *test1, int *test2, int *test3)
{
// Promts
printf("\nHello, this program will determine");
printf("\nthe grades of an average test scores");
printf("\nto see if you passed or not this year.");
printf("\nPlease enter in the three test...");
printf("\nNote: only enter scores that are (0-100)\n");
printf("Enter in test 1\n");
scanf(" %d", test1);
printf("Enter in test 2\n");
scanf(" %d", test2);
printf("Enter in test 3\n");
scanf(" %d", test3);
return;
}
int determineAverage(int test1, int test2, int test3)
{
// Local declrations
int average;
// Math
average = (test1 + test2 + test3)/3;
return average;
}
void print(int test3, int average, int test2_test3Av)
{
if (average >= 90)
{
printf("Great job you have an A %d int the class\n", average);
}
else if (average >= 70 && average <= 90, test3)
{
if (test3 >= 90)
{
printf("Good job you got a A %d\n", average);
}
else if
{
printf("Easy Beezy you got a B %d for the class\n", average);
}
}
else if (average >= 50 && average <= 70)
{
if (test2_test3Av >= 70)
{
printf("You passed congrats you have a C %d for the class\n", average);
}
else if
{
printf("You have a D for the class %d\n", average);
}
}
else if (average <= 50)
{
printf("Yeah you might want to take this class again you have a F %d\n", average);
}
return;
}
int avgtest2test3(int test2, int test3)
{
int holder;
holder = ((test2 + test3)/2);
return holder;
}
歡迎來到[StackOverflow的](http://stackoverflow.com)。請花一些時間閱讀 [幫助頁面](http://stackoverflow.com/help),尤其是名爲[「我可以問什麼問題?」](http://stackoverflow.com/help /主題)和[「我應該避免問什麼類型的問題?」](http://stackoverflow.com/help/dont-ask)。更重要的是,請閱讀[Stack Overflow問題清單](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist)。您可能還想了解[SSCCE](http://www.sscce.org/)是什麼。 – hivert
顯示的代碼中不存在任何循環。 – alk