主题:编译没错,为什么老运行部了
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{int red[33],blue[16],num1=6,num2=1,max_mid1=33,max_mid2=16,i,j;
int chosered[6],choseblue,choice_r,choice_b;
char ch1,ch2;
printf("**********欢迎购买中国福利彩票------双色球**************\n");
printf("~~~~奉献一份爱心,收获一份意外的喜悦,祝你好运!~~~~~~~~~~~~~~\n" );
printf(" 您是否采用机选(y/n):");
scanf("%c",ch1);
if(toupper(ch1)=='Y')
{do
{ for(i=0;i<max_mid1;i++) /*所有的红球*/
{
red[i]=i+1;
}
srand((unsigned)time(NULL)); /*随机取出6红球*/
for(i=0;i<num1;i++)
{choice_r=rand()%max_mid1;
chosered[i]=red[choice_r];
for(j=choice_r;j<max_mid1;j++)
{red[j]=red[j+1];
}
max_mid1--;
}
for(i=0;i<max_mid2;i++) /*所有的蓝球*/
{
blue[i]=i+1;
}
srand((unsigned)time(NULL)); /*随机取出1蓝球*/
choice_b=rand()%max_mid2;
choseblue=blue[choice_b];
printf("本注双色球机选的号码为:"); /*号码输出*/
printf("红球为:");
for(i=0;i<num1;i++)
{printf(" %d",chosered[i]);
}
printf(" 蓝球为:%d",choseblue);
printf("是否再选一注(y/n)");
scanf("%c",ch2);
}while(toupper(ch2)=='Y');
}
else
{printf("请输入你所选的号码");
}
getch();
return 0;
}
#include<conio.h>
#include<time.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{int red[33],blue[16],num1=6,num2=1,max_mid1=33,max_mid2=16,i,j;
int chosered[6],choseblue,choice_r,choice_b;
char ch1,ch2;
printf("**********欢迎购买中国福利彩票------双色球**************\n");
printf("~~~~奉献一份爱心,收获一份意外的喜悦,祝你好运!~~~~~~~~~~~~~~\n" );
printf(" 您是否采用机选(y/n):");
scanf("%c",ch1);
if(toupper(ch1)=='Y')
{do
{ for(i=0;i<max_mid1;i++) /*所有的红球*/
{
red[i]=i+1;
}
srand((unsigned)time(NULL)); /*随机取出6红球*/
for(i=0;i<num1;i++)
{choice_r=rand()%max_mid1;
chosered[i]=red[choice_r];
for(j=choice_r;j<max_mid1;j++)
{red[j]=red[j+1];
}
max_mid1--;
}
for(i=0;i<max_mid2;i++) /*所有的蓝球*/
{
blue[i]=i+1;
}
srand((unsigned)time(NULL)); /*随机取出1蓝球*/
choice_b=rand()%max_mid2;
choseblue=blue[choice_b];
printf("本注双色球机选的号码为:"); /*号码输出*/
printf("红球为:");
for(i=0;i<num1;i++)
{printf(" %d",chosered[i]);
}
printf(" 蓝球为:%d",choseblue);
printf("是否再选一注(y/n)");
scanf("%c",ch2);
}while(toupper(ch2)=='Y');
}
else
{printf("请输入你所选的号码");
}
getch();
return 0;
}