码迷,mamicode.com
首页 > 编程语言 > 详细

用C语言写的双色球

时间:2016-05-29 22:53:12      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

double jieguo();

void main(){

         int i,k;

         int m,n;

         int j;

         printf("请输入购买的号码:\n");

         scanf("%d",&i);

         j=jieguo();

         if(i==j)

                   printf("赢得的金额是500元\n");

         if(i%100==j%100)

                   printf("赢得的金额是150元\n");

         for(m=1;m<=5;m++){

                   i=i%100;

                   for(k=1,n=0;k<=5;k++){

                            j=j%100;

                            if(i==j)

                                     n=n+1;

                   }

         }

         printf("%d\n",n);

         if(n==5&&j%100==i%100)

                   printf("奖金是3000\n");

         if((n==5&&j%100!=i%100)||(n==4&&j%100==i%100))

                   printf("奖金是200\n");

         if((n==4&&j%100!=i%100)||(n==3&&j%100==i%100))

                   printf("奖金是10\n");

         if((n==2&&j%100==i%100)||(n==1&&j%100==i%100)||(n==0&&j%100==i%100))

                   printf("奖金是5\n");

}

 

 

 

 

double jieguo(){

         int a,b;

         int i;

         double sum;

         srand(time(NULL));

         for(i=1,sum=0;i<=6;i++){

                  

                   a=rand()%37;

                   //printf("%d\n",a);

                   sum=sum*100;

                   sum +=a;

         }

         b=rand()%17;

         sum=sum*100+b;

         return sum;

}

用C语言写的双色球

标签:

原文地址:http://www.cnblogs.com/yjh123/p/5540520.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!