March 29, 2010

隨機抽籤

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

int main(void)
{
  int i,score[55],k,flag=0;
  //srand(time(NULL));
  for(i=1;i<=20;i++)
   {
    score[i]=1+rand()%51;flag=0;
    for(k=0;k<i;k++)
     {if (score[i]==score[k]) flag=1;}
     if(flag==0)  
       printf("%2d",score[i]);
     else  i--;
    if(i%5==0){printf("\n");}
      }
   
  

          system("pause");
          return 0;
 }

0推薦此文章
Today's Visitors: 0 Total Visitors: 36
Personal Category: Uncategorized Articles Topic: technology / tech info / programming
[Trackback URL]

Reply
  • 1樓

    1樓搶頭香

    Sealed

  • Sealed at May 17, 2010 12:55 PM comment
  • 2樓

    2樓頸推

    Sealed

  • Sealed at August 24, 2010 03:54 AM comment
  • Sealed

  • Blog Owner at August 29, 2010 09:13 AM Reply
  • 3樓

    3樓坐沙發

    http://www.facebook.com/profile.php?id=100001104901571
    我的

  • peggyrong at August 29, 2010 12:49 PM comment | prosecute
  • 偶知

  • Blog Owner at September 5, 2010 08:59 AM Reply

Only friends can post a comment, Login first

誰來收藏
Loading ...
unlog_NVPO 0