Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<time.h>
  3. #include<stdlib.h>
  4. #include<math.h>
  5. #include <string.h>
  6.  
  7. int main()
  8. {
  9. int m,n,N,G,i,v;
  10. long int sum=0;
  11. srand((unsigned) time(NULL));
  12. scanf("%d %d",&N,&G);
  13. int a[G],b[G],used[N+1];
  14. memset(used,0,N+1);
  15. for(m=0;m<G;m++)
  16. {
  17. do{
  18. n=rand()%N+1;
  19. }while(used[n]==1);
  20. used[n]=1;
  21. printf("%d",n);
  22. }
  23. printf("\nGuess %d number between 1-%d: ",G,N);
  24. scanf("%d",&i);
  25. for(m=0;m<G;m++)
  26. {
  27.  
  28. v=pow((int)10.0000,m+1);
  29. if(v%10)
  30. b[m]=(i%v)/(v/10);
  31. printf("%d\n%d\n",v,b[m]);
  32. i=i-(b[m]*pow(10,m));
  33. printf("%d\n\n",i);
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement