Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main(void)
- {
- int i;
- int num,no[100];
- int count=0;
- srand(time(NULL));
- ///////////////////陣列歸零//////////////////////
- for (i=0;i<=100;i++)
- no[i]=0;
- //////////////////隨機產生不重複的數字///////////
- while(count<10)
- {
- num=rand()%91+10;
- if(no[num]==0)
- {
- no[num]=1;
- count++;
- }
- }
- //////////////////找出最大值與最小值//////////////
- FILE *written;
- written=fopen("random01.txt","w");
- printf("開出的號碼是:\n");
- for(i=0;i<=100;i++)
- {
- if(no[i]==1)
- {
- printf("%d\n",i);
- fprintf(written,"%d ",i);
- }
- }
- close(written);
- printf("==================================");
- printf("\n寫檔完成");
- printf("\n==================================\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement