问题描述
- 求解代码为甚在DEVCPP 下运行出错
-
#include/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int heads()
{
srand((unsigned)time(NULL));
return rand()<RAND_MAX/2;
}int main(int argc, char argv[]) {
int i,j,cnt;
int N=atoi(argv[1]),M=atoi(argv[2]);
int *f=malloc((N+1)*sizeof(int));
for(j=0;j<=N;j++)f[j]=0;
for(i=0;i<M;i++,f[cnt]++)
for(cnt=0,j=0;j<=N;j++)
if(heads())cnt++;
for(j=0;j<=N;j++)
{
printf("%2d",j);
for(i=0;i<f[j];i+=10)printf("");
printf("n");
}
return 0;
}
时间: 2024-10-28 06:16:46