囧Sir 发表于 2016-8-8 14:00:57

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

{:5_96:}


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

        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);
                if(strlen(a) == 8)
                {
                        ban++;
                }
                else if(strlen(a) == 10)
                {
                        tu++;
                }
                else if(strlen(a) == 6)
                {
                        xiao++;
                }
                else
                {
                        printf("\n没有这个人(●··●!)\n");
                }
                i++;
        }

        printf("\n一号的票数:%d\n",ban);
        printf("二号的票数:%d\n",tu);
        printf("三号的票数:%d\n",xiao);
       
        return 0;
}

囧Sir 发表于 2016-8-8 14:02:34

不不我还没解决啊!是手抽了误点的{:5_107:}
页: [1]
查看完整版本: 终于写完了小甲鱼大大给的《结构体投票》求改进