You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.8 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 <iostream>
int main()
{
struct student
{
int number;
float gaoshu;
float dawu;
float yy;
float add;
}student1, student2, student3;
scanf_s("%d%f%f%f", &student1.number, &student1.gaoshu, &student1.dawu, &student1.yy);
scanf_s("%d%f%f%f", &student2.number, &student2.gaoshu, &student2.dawu, &student2.yy);
scanf_s("%d%f%f%f", &student3.number, &student3.gaoshu, &student3.dawu, &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);
}