1 #include<stdio.h> 2 3 #include<stdlib.h> 4 5 #include<time.h> 6 7 double jieguo(); 8 9 void main(){ 10 11 int i,k; 12 13 int m,n; 14 15 int j; 16 17 printf("请输入购买的号码:\n"); 18 19 scanf("%d",&i); 20 21 j=jieguo(); 22 23 if(i==j) 24 25 printf("赢得的金额是500元\n"); 26 27 if(i%100==j%100) 28 29 printf("赢得的金额是150元\n"); 30 31 for(m=1;m<=5;m++){ 32 33 i=i%100; 34 35 for(k=1,n=0;k<=5;k++){ 36 37 j=j%100; 38 39 if(i==j) 40 41 n=n+1; 42 43 } 44 45 } 46 47 printf("%d\n",n); 48 49 if(n==5&&j%100==i%100) 50 51 printf("奖金是3000\n"); 52 53 if((n==5&&j%100!=i%100)||(n==4&&j%100==i%100)) 54 55 printf("奖金是200\n"); 56 57 if((n==4&&j%100!=i%100)||(n==3&&j%100==i%100)) 58 59 printf("奖金是10\n"); 60 61 if((n==2&&j%100==i%100)||(n==1&&j%100==i%100)||(n==0&&j%100==i%100)) 62 63 printf("奖金是5\n"); 64 65 } 66 67 68 69 70 71 72 73 74 75 double jieguo(){ 76 77 int a,b; 78 79 int i; 80 81 double sum; 82 83 srand(time(NULL)); 84 85 for(i=1,sum=0;i<=6;i++){ 86 87 88 89 a=rand()%37; 90 91 //printf("%d\n",a); 92 93 sum=sum*100; 94 95 sum +=a; 96 97 } 98 99 b=rand()%17; 100 101 sum=sum*100+b; 102 103 return sum; 104 105 }