c++新手,請高手回答

2012-12-04 6:04 am
請問以下程式碼有甚麼問題?

#include<stdio.h> //title
#include<stdlib.h>
#include<time.h>

#define N 20
{
int arr[N],x,n,i;
int f=-1

srand(time(NULL)); //random seed
for(i=0;i<N;i++)
{
arr[i]=rand()/1000; //in order
}

printf('enter numbers:");
scanf("%d",&x); //enter numbers

{ //find in order
if(x==arr[i])
{
f=i;
break
}
}
printf("\n random numbers:\n");
for(i=0;i<N;i++)
{
printf("%d",arr[i]); //output
}
printf('\n\n");
if(f<0)
{
printf("can not find:%d\n".x);
}
else
{
printf("data:%d at the order of %d element\n",x,f+1);
}

system("pause");
return 0;
}

回答 (1)

2012-12-04 7:08 am
✔ 最佳答案
問題在於你冇定明個 main 係邊度開始


收錄日期: 2021-04-13 19:08:57
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20121203000051KK00410

檢視 Wayback Machine 備份