鱼C论坛

 找回密码
 立即注册
查看: 6257|回复: 1

终于写完了小甲鱼大大给的《结构体投票》求改进

[复制链接]
发表于 2016-8-8 14:00:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x



#include<stdio.h>       
#include<string.h>
        struct competitor
        {
                int num;
                char name[20];               
        };
               
int main()
{
        int  i = 0 , j;
        int  ban = 0 , tu = 0 , xiao = 0 ;                                   //计算三人得票数
        char a[20][20];

        struct competitor competitor1 = { 1 , "坂田银时"   };
        struct competitor competitor2 = { 2 , "土方十四郎" };
        struct competitor competitor3 = { 3 , "小神乐"            };

        printf("\t选手编号\t\t\t选手名\n");
        printf("\t%d\t\t\t\t%s\n",competitor1.num ,competitor1.name );
        printf("\t%d\t\t\t\t%s\n",competitor2.num ,competitor2.name );
        printf("\t%d\t\t\t\t%s\n",competitor3.num ,competitor3.name );
                                                                          //介绍选手
        printf("\n\t那么,开始投票吧!\n\n");
       
        while( i < 12)
        {
                j = i +1;
                printf("第%d张票投给的选手是:",j );
            scanf("%s",&a[i]);
                if(strlen(a[i]) == 8)
                {
                        ban++;
                }
                else if(strlen(a[i]) == 10)
                {
                        tu++;
                }
                else if(strlen(a[i]) == 6)
                {
                        xiao++;
                }
                else
                {
                        printf("\n没有这个人(●··●!)\n");
                }
                i++;
        }

        printf("\n一号的票数:%d\n",ban);
        printf("二号的票数:%d\n",tu);
        printf("三号的票数:%d\n",xiao);
       
        return 0;
}
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2016-8-8 14:02:34 | 显示全部楼层
不不我还没解决啊!是手抽了误点的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-11 10:13

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表