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,max=0,min=10;
- int num,no[10];
- int count=0;
- srand(time(NULL));
- //////////////////陣列歸零////////////////////////
- for (i=0;i<=9;i++)
- no[i]=0;
- /////////////////隨機產生不重複的數字/////////////
- while(count<5)
- {
- num=rand()%10;
- if(no[num]==0)
- {
- no[num]=1;
- count++;
- }
- }
- for(i=0;i<=9;i++)
- {
- if(no[i]==1)
- {
- printf("%d ",i);
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement