***********第一题**********
long a; //陌生人给富翁,单位万
long b; //富翁给陌生人,单位分
int main()
{
int i;
long todaygive;
todaygive=1;
for(i=0;i<30;i++)
{a+=10;
b+=todaygive;
todaygive*=2;
}
printf("陌生人给富翁:%ld0000元\n",a);
printf("富翁给陌生人:%ld.%ld元",b/100,b%100);
getchar();
}
***********第二题**********
struct student{
char name[20];
int score[3];
int ave;
}student[5];
int input()
{
int i;
for(i=0;i<5;i++)
{
printf("Student %d:",i+1);
gets(student[i].name);
printf("语文:");
scanf("%d",&student[i].score[0]);
printf("数学:");
scanf("%d",&student[i].score[1]);
printf("计算机:");
scanf("%d",&student[i].score[2]);
getchar();
student[i].ave=student[i].score[0]+student[i].score[1]+student[i].score[2];
student[i].ave/=3;
}
}
int print()
{
int i;
int max=0;
int maxid=0;
printf("%20s%5s%5s%7s%5s\n","姓名","语文","数学","计算机","平均");
for(i=0;i<5;i++)
{if(student[i].ave>=60)
printf("%20s%5d%5d%7d%5d\n",student[i].name,student[i].score[0],student[i].score[1],student[i].score[2],student[i].ave);
if(student[i].ave>max) {maxid=i; max=student[i].ave;}
}
printf("最高分:%s",student[maxid].name);
}
int main()
{
input();
print();
getchar();
getchar();
}
**************第三题****************
int main()
{
int i=0,j=0,k=0,l=0;
int count=0;
printf("%4s%4s%4s%4s\n","10元","5元","2元","1元");
for(i=1;i<10;i++)
for(j=1;j<20;j++)
for(k=1;k<40;k++)
for(l=1;l<40;l++)
{
if(i+j+k+l==40&&i*10+j*5+k*2+l==100)
{printf("%4d%4d%4d%4d\n",i,j,k,l);
count++;
}
}
printf("共有%d种换法.",count);
getchar();
}
************第四题***********
int b1,b2,b3;
char color[4][7]={"Red","While","Yellow","Blue"};
int count;
int main()
{
for(b1=0;b1<4;b1++)
for(b2=0;b2<4;b2++)
for(b3=0;b3<4;b3++)
if(b1!=b2&&b2!=b3&&b3!=b1)
{printf("%7s%7s%7s\n",color[b1],color[b2],color[b3]);
count++;
}printf("Total:%d",count);
getchar();
}
回答者:soyboydoy - 助理 三级 6-21 19:03
答了这么多建议加最佳
温馨提示:答案为网友推荐,仅供参考