马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
void main()
{
struct str{
char *name;
int score;
} boy1, boy2, boy3, boy4;
int l;
int i;
boy1.name="小甲鱼";
boy2.name="莫丁丁";
boy3.name="黑夜";
boy4.name="苍井空";
boy1.score=1;
boy2.score=2;
boy3.score=3;
boy4.score=4;
printf("投票系统,正在进行\n");
for(i=0;i<9;i++)
{
printf("1.小甲鱼,2.莫丁丁,3.黑夜,4.苍井空\n");
scanf("%d",&l);
if(l==1)
{
boy1.score++;
}
if(l==2)
{
boy2.score++;
}
if(l==3)
{
boy3.score++;
}
if(l==4)
{
boy4.score++;
}
}
printf("小甲鱼获得%d票\n", boy1.score);
printf("莫丁丁获得%d票\n", boy2.score);
printf("黑夜获得%d票\n", boy3.score);
printf("苍井空获得%d票\n", boy4.score);
}
怎么排序呢?这代码有点不全面,希望有人指点。 |