4.3 KiB
步骤1 int main() { char controll; char arr1[] = { " 1.Input" }; char arr2[] = { " 2.Output" }; char arr3[] = { " 3.Order" }; char arr4[] = { " 4.Quit" }; char arr5[] = { "You are trying to Input info" }; char arr6[] = { "You are trying to Output info" }; char arr7[] = { "You are trying to Make things ordered" }; char arr8[] = { "You are about to Quit" }; printf("%s\n%s\n%s\n%s\n", arr1, arr2, arr3, arr4); scanf_s("%c", &controll); switch (controll) { case 'i':printf("\n%s\n", arr5); break; case 'o':printf("\n%s\n", arr6); break; case 'm':printf("\n%s\n", arr7); break; case 'q':printf("\n%s\n", arr8); break; default:printf("Wrong input"); }
} 步骤2 #include
int main() { struct student { int number; float gaoshu; float dawu; float yy; float add; }student1, student2, student3; scanf("%d",&student1.number); scanf("%f",&student1.gaoshu); scanf("%f",&student1.dawu); scanf("%f",&student1.yy); scanf("%d",&student2.number); scanf("%f",&student2.gaoshu); scanf("%f",&student2.dawu); scanf("%f",&student2.yy); scanf("%d",&student3.number); scanf("%f",&student3.gaoshu); scanf("%f",&student3.dawu); scanf("%f",&student3.yy); student1.add = (student1.gaoshu + student1.dawu + student1.yy); student2.add = (student2.gaoshu + student2.dawu + student2.yy); student3.add = (student3.gaoshu + student3.dawu + student3.yy); printf("%d %f %f %f %f\n", student1.number, student1.gaoshu, student1.dawu, student1.yy, student1.add);
printf("%d %f %f %f %f\n", student2.number, student2.gaoshu, student2.dawu, student2.yy, student2.add);
printf("%d %f %f %f %f\n", student3.number, student3.gaoshu, student3.dawu, student3.yy, student3.add); } 步骤3 int main() { char controll; char arr1[] = { " 1.Input" }; char arr2[] = { " 2.Output" }; char arr3[] = { " 3.Order" }; char arr4[] = { " 4.Quit" }; char arr5[] = { "Please input info of the three students:" }; char arr7[] = { "You are trying to Make things ordered" }; char arr8[] = { "You are about to Quit" }; printf("%s\n%s\n%s\n%s\n", arr1, arr2, arr3, arr4); scanf_s("%c", &controll); switch (controll) { case 'i':printf("\n%s\n", arr5); break; case 'm':printf("\n%s\n", arr7); break; case 'q':printf("\n%s\n", arr8); break; default:printf("Wrong input"); } struct student { int number; float gaoshu; float dawu; float yy; float add; float aver; }student1, student2, student3,studenttemp; scanf("%d",&student1.number); scanf("%f",&student1.gaoshu); scanf("%f",&student1.dawu); scanf("%f",&student1.yy); scanf("%d",&student2.number); scanf("%f",&student2.gaoshu); scanf("%f",&student2.dawu); scanf("%f",&student2.yy); scanf("%d",&student3.number); scanf("%f",&student3.gaoshu); scanf("%f",&student3.dawu); scanf("%f",&student3.yy); student1.add = (student1.gaoshu + student1.dawu + student1.yy); student2.add = (student2.gaoshu + student2.dawu + student2.yy); student3.add = (student3.gaoshu + student3.dawu + student3.yy); student1.aver = student1.add / 3; student2.aver = student2.add / 3; student3.aver = student3.add / 3; if (student1.add > student2.add) { studenttemp = student1; student1 = student2; student2 = studenttemp; } if (student1.add > student3.add) { studenttemp = student1; student1 = student3; student3 = studenttemp; } if (student2.add > student3.add) { studenttemp = student2; student2 = student3; student3 = studenttemp; } printf("%d,%.1f,%.1f\n", student1.number, student1.add, student1.aver); printf("%d,%.1f,%.1f\n", student2.number, student2.add, student2.aver); printf("%d,%.1f,%.1f\n", student3.number, student3.add, student3.aver);
}