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.
485 lines
10 KiB
485 lines
10 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("%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);
|
|
|
|
|
|
}
|
|
步骤四
|
|
#include <stdio.h>
|
|
int num[4],cla[4];
|
|
float f[4],s[4],t[4],add[4];
|
|
int begin,sta;
|
|
int n=4;
|
|
int insert;
|
|
void sort(float add[])
|
|
{
|
|
int i,j,te;
|
|
float zh;
|
|
for(i=n-1;i>sta;i--)
|
|
{
|
|
if(add[i]>add[i-1])
|
|
{
|
|
zh=add[i];add[i]=add[i-1];add[i-1]=zh;
|
|
te=num[i];num[i]=num[i-1];num[i-1]=te;
|
|
zh=f[i];f[i]=f[i-1];f[i-1]=zh;
|
|
zh=s[i];s[i]=s[i-1];s[i-1]=zh;
|
|
zh=t[i];t[i]=t[i-1];t[i-1]=zh;
|
|
}
|
|
}
|
|
if(n!=sta+1)
|
|
{
|
|
sta++;
|
|
sort(add);}
|
|
}
|
|
|
|
void div(int clas[])
|
|
{
|
|
int i,j,te;
|
|
float zh;
|
|
for(i=0;i<n-1;i++)
|
|
{
|
|
if(clas[i]>clas[i+1])
|
|
{
|
|
te=clas[i];clas[i]=clas[i+1];clas[i+1]=te;
|
|
zh=add[i];add[i]=add[i+1];add[i+1]=zh;
|
|
te=num[i];num[i]=num[i+1];num[i+1]=te;
|
|
zh=f[i];f[i]=f[i+1];f[i+1]=zh;
|
|
zh=s[i];s[i]=s[i+1];s[i+1]=zh;
|
|
zh=t[i];t[i]=t[i+1];t[i+1]=zh;
|
|
}
|
|
}
|
|
if(n!=sta+1){
|
|
n--;
|
|
div(clas);}
|
|
|
|
}
|
|
|
|
int main()
|
|
{
|
|
void sort(float add[]);
|
|
void div(int clas[]);
|
|
num[0]=10001;num[1]=10002;num[2]=10003;
|
|
cla[0]=11;cla[1]=12;cla[2]=11;
|
|
f[0]=99.5;f[1]=77.9;f[2]=92.5;
|
|
s[0]=88.5;s[1]=56.5;s[2]=99.0;
|
|
t[0]=89.5;t[1]=87.5;t[2]=60.5;
|
|
for(int i=0;i<3;i++)
|
|
{
|
|
add[i]=f[i]+s[i]+t[i];
|
|
}
|
|
scanf("%d",&num[3]);
|
|
insert=num[3];
|
|
int in=num[3];
|
|
for(int i=0;i<3;i++){
|
|
if(in==num[i]){
|
|
printf("%d %d %f %f %f %f",num[i],cla[i],f[i],s[i],t[i],add[i]);
|
|
return 0;
|
|
}
|
|
}
|
|
scanf("%d",&cla[3]);
|
|
scanf("%f",&f[3]);
|
|
scanf("%f",&s[3]);
|
|
scanf("%f",&t[3]);
|
|
add[3]=f[3]+s[3]+t[3];
|
|
sta=0;begin=0;
|
|
div(cla);
|
|
n=4;
|
|
int m;
|
|
for(m=0;m<n;m++){
|
|
if(cla[m]!=cla[m+1])
|
|
break;
|
|
}
|
|
sta=m;begin=sta;
|
|
sort(add);
|
|
n=m+1;
|
|
sta=0;begin=sta;
|
|
sort(add);
|
|
n=4;
|
|
for(int j=0;j<n;j++){
|
|
printf("%d %d %f %f %f %f",num[j],cla[j],f[j],s[j],t[j],add[j]);
|
|
if(num[j]==insert) printf(" insert\n");
|
|
else printf("\n");
|
|
}
|
|
|
|
}
|
|
步骤五
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
int num[4],cla[4];
|
|
float f[4],s[4],t[4],add[4];
|
|
int begin,sta;
|
|
int n=3;
|
|
int insert;
|
|
char name[4][10]={{"Zhang"},{"Yang"},{"Liang"}};
|
|
void sort(float add[])
|
|
{
|
|
int i,j,te;
|
|
float zh;
|
|
char oo[10];
|
|
for(i=n-1;i>sta;i--)
|
|
{
|
|
if(add[i]>add[i-1])
|
|
{
|
|
zh=add[i];add[i]=add[i-1];add[i-1]=zh;
|
|
te=num[i];num[i]=num[i-1];num[i-1]=te;
|
|
zh=f[i];f[i]=f[i-1];f[i-1]=zh;
|
|
zh=s[i];s[i]=s[i-1];s[i-1]=zh;
|
|
zh=t[i];t[i]=t[i-1];t[i-1]=zh;
|
|
strcpy(oo,name[i]);strcpy(name[i],name[i-1]);
|
|
strcpy(name[i-1],oo);
|
|
}
|
|
}
|
|
if(n!=sta+1)
|
|
{
|
|
sta++;
|
|
sort(add);}
|
|
}
|
|
|
|
void div(int clas[])
|
|
{
|
|
int i,j,te;
|
|
float zh;
|
|
char oo[10];
|
|
for(i=0;i<n-1;i++)
|
|
{
|
|
if(clas[i]>clas[i+1])
|
|
{
|
|
te=clas[i];clas[i]=clas[i+1];clas[i+1]=te;
|
|
zh=add[i];add[i]=add[i+1];add[i+1]=zh;
|
|
te=num[i];num[i]=num[i+1];num[i+1]=te;
|
|
zh=f[i];f[i]=f[i+1];f[i+1]=zh;
|
|
zh=s[i];s[i]=s[i+1];s[i+1]=zh;
|
|
zh=t[i];t[i]=t[i+1];t[i+1]=zh;
|
|
strcpy(oo,name[i]);strcpy(name[i],name[i+1]);
|
|
strcpy(name[i+1],oo);
|
|
}
|
|
}
|
|
if(n!=sta+1){
|
|
n--;
|
|
div(clas);}
|
|
|
|
}
|
|
|
|
|
|
int main()
|
|
{
|
|
void sort(float add[]);
|
|
void div(int clas[]);
|
|
num[0]=10001;num[1]=10002;num[2]=10003;
|
|
cla[0]=11;cla[1]=12;cla[2]=11;
|
|
f[0]=99.5;f[1]=77.9;f[2]=92.5;
|
|
s[0]=88.5;s[1]=56.5;s[2]=99.0;
|
|
t[0]=89.5;t[1]=87.5;t[2]=60.5;
|
|
sta=0;begin=0;
|
|
div(cla);
|
|
n=3;
|
|
int m;
|
|
for(m=0;m<n;m++){
|
|
if(cla[m]!=cla[m+1])
|
|
break;
|
|
}
|
|
sta=m;begin=sta;
|
|
sort(add);
|
|
n=m+1;
|
|
sta=0;begin=sta;
|
|
sort(add);
|
|
n=3;
|
|
scanf("delete");
|
|
scanf("%s",name[3]);
|
|
int exist=0,target;
|
|
if(name[3][0]>='0'&&name[3][0]<='9')
|
|
{
|
|
int number=atoi(name[3]);
|
|
for(int i=0;i<3;i++){
|
|
if(number==num[i]){
|
|
printf("Are you sure?");
|
|
exist=1;
|
|
target=i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(int i=0;i<3;i++){
|
|
if(strcmp(name[i],name[3]));
|
|
else{
|
|
printf("Are you sure?\n");
|
|
exist=1;
|
|
target=i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
char ch;
|
|
if(exist==1){
|
|
scanf(" %c",&ch);
|
|
if(ch=='y'){
|
|
for(int i=0;i<3;i++){
|
|
if(i!=target){
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
}
|
|
}
|
|
}
|
|
if(ch=='n'){
|
|
for(int i=0;i<3;i++){
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
for(int i=0;i<3;i++){
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
步骤六
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
int num[4],cla[4];
|
|
float f[4],s[4],t[4],add[4];
|
|
int begin,sta;
|
|
int n=3;
|
|
int insert;
|
|
char name[4][10]={{"Zhang"},{"Yang"},{"Liang"}};
|
|
void sort(float add[])
|
|
{
|
|
int i,j,te;
|
|
float zh;
|
|
char oo[10];
|
|
for(i=n-1;i>sta;i--)
|
|
{
|
|
if(add[i]>add[i-1])
|
|
{
|
|
zh=add[i];add[i]=add[i-1];add[i-1]=zh;
|
|
te=num[i];num[i]=num[i-1];num[i-1]=te;
|
|
zh=f[i];f[i]=f[i-1];f[i-1]=zh;
|
|
zh=s[i];s[i]=s[i-1];s[i-1]=zh;
|
|
zh=t[i];t[i]=t[i-1];t[i-1]=zh;
|
|
strcpy(oo,name[i]);strcpy(name[i],name[i-1]);
|
|
strcpy(name[i-1],oo);
|
|
}
|
|
}
|
|
if(n!=sta+1)
|
|
{
|
|
sta++;
|
|
sort(add);}
|
|
}
|
|
|
|
void div(int clas[])
|
|
{
|
|
int i,j,te;
|
|
float zh;
|
|
char oo[10];
|
|
for(i=0;i<n-1;i++)
|
|
{
|
|
if(clas[i]>clas[i+1])
|
|
{
|
|
te=clas[i];clas[i]=clas[i+1];clas[i+1]=te;
|
|
zh=add[i];add[i]=add[i+1];add[i+1]=zh;
|
|
te=num[i];num[i]=num[i+1];num[i+1]=te;
|
|
zh=f[i];f[i]=f[i+1];f[i+1]=zh;
|
|
zh=s[i];s[i]=s[i+1];s[i+1]=zh;
|
|
zh=t[i];t[i]=t[i+1];t[i+1]=zh;
|
|
strcpy(oo,name[i]);strcpy(name[i],name[i+1]);
|
|
strcpy(name[i+1],oo);
|
|
}
|
|
}
|
|
if(n!=sta+1){
|
|
n--;
|
|
div(clas);}
|
|
|
|
}
|
|
|
|
|
|
int main()
|
|
{
|
|
void sort(float add[]);
|
|
void div(int clas[]);
|
|
num[0]=10001;num[1]=10002;num[2]=10003;
|
|
cla[0]=11;cla[1]=12;cla[2]=11;
|
|
f[0]=99.5;f[1]=77.9;f[2]=92.5;
|
|
s[0]=88.5;s[1]=56.5;s[2]=99.0;
|
|
t[0]=89.5;t[1]=87.5;t[2]=60.5;
|
|
sta=0;begin=0;
|
|
div(cla);
|
|
n=3;
|
|
int m;
|
|
for(m=0;m<n;m++){
|
|
if(cla[m]!=cla[m+1])
|
|
break;
|
|
}
|
|
sta=m;begin=sta;
|
|
sort(add);
|
|
n=m+1;
|
|
sta=0;begin=sta;
|
|
sort(add);
|
|
n=3;
|
|
int i;
|
|
int changer1,changer2,target,input;
|
|
float changer4,changer5,changer6;
|
|
scanf("%d",&changer1);
|
|
for(i=0;i<3;i++){
|
|
if(num[i]==changer1){input=1;break;}
|
|
else input=0;
|
|
}
|
|
char changer[10];
|
|
scanf("%d",&changer2);
|
|
scanf("%s",changer);
|
|
scanf("%f",&changer4);
|
|
scanf("%f",&changer5);
|
|
scanf("%f",&changer6);
|
|
if(input==0){
|
|
for(i=0;i<3;i++){
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
i=target;
|
|
cla[i]=changer2;strcpy(name[i],changer);f[i]=changer4;
|
|
s[i]=changer5;t[i]=changer6;
|
|
sta=0;begin=0;
|
|
div(cla);
|
|
n=3;
|
|
int m;
|
|
for(m=0;m<n;m++){
|
|
if(cla[m]!=cla[m+1])
|
|
break;
|
|
}
|
|
sta=m;begin=sta;
|
|
sort(add);
|
|
n=m+1;
|
|
sta=0;begin=sta;
|
|
sort(add);
|
|
for(i=0;i<3;i++){
|
|
printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]);
|
|
}
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|