标题:双色球中奖问题, 运行时怎么不出结果? 求大神帮忙
取消只看楼主
电子华人
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-10-14
结帖率:0
已结贴  问题点数:5 回复次数:1 
双色球中奖问题, 运行时怎么不出结果? 求大神帮忙
#include<stdio.h>
int main()
{
    int red[] = {3,5,12,15,20,27};
    int blue = 4;
    int i,j,a[10],B,count = 0,flag = 0;

    printf("请输入一注号码\n红色球为:\n");
    for(i =0; i < 6 ;i++)
        scanf("%d",&a[i]);
    printf("蓝色球号码为:\n");
    scanf("%d",B);

    for(i =0;i < 6;i++)
        for(j = 0; j < 6;j++)
            if( red[i] == a[j]){
                count++;
            }

        if(B == 4)
            flag = 1;



        if(count == 6 && flag == 1)
            printf("中了一等奖!\n");
        else if(count == 6 && flag ==0)
            printf("中了二等奖!\n");
        else if(count == 5 && flag == 1)
            printf("中了三等奖!\n");
        else if((count == 5 && flag == 0)  || (count == 4 && flag == 1))
            printf("中了四等奖!\n");
        else if((count == 4 && flag == 0)  || (count == 3 && flag == 1))
            printf("中了五等奖!\n");
        else if((count == 2 && flag == 1) || (count == 1 && flag == 1)  || (count == 0 && flag == 1))
            printf("中了六等奖!\n");
        else
            printf("对不起没有中奖!\n");
        return 0;
            
}
搜索更多相关主题的帖子: 双色球中奖 include count 
2013-10-14 21:31
电子华人
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-10-14
得分:0 
2013-10-14 21:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-421896-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031325 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved