fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. enum {MYSIZE=6,MYASIZE=49};
  6.  
  7. int enthaelt(const int *a,int z)
  8. {
  9. int i;
  10. for(i=0;i<MYSIZE;++i)
  11. if(a[i]==z) return 1;
  12. return 0;
  13. }
  14.  
  15. int main()
  16. {
  17. int i, x, array[MYSIZE]={0};
  18.  
  19. srand(time(0)); //Zufallszahlengenerator
  20.  
  21. for(i=0; i<MYSIZE; i++) // Schleife zur Bestimmung der 6 Felder
  22. {
  23. while( enthaelt(array,x=rand()%MYASIZE+1) );
  24. printf(" %d ",array[i]=x);
  25. }
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 4560KB
stdin
Standard input is empty
stdout
 11  7  27  9  44  21