Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. int x,x1,n,s,i,a[999],sum1,sum2,k,k1;
  5. int main()
  6. {
  7. srand(time(NULL));
  8. printf("Enter s = ");
  9. scanf("%i",&s);
  10. printf("Enter n = ");
  11. scanf("%i",&n);
  12. k=0;
  13. for (i=0; i<s; i++)
  14. {
  15. a[i]=rand () % 89999;
  16. k1=rand() % 9 + 1;
  17. a[i]=k1*100000 + 99999-a[i];
  18. x=a[i]/1000;
  19. x1=a[i]%1000;
  20. sum1=x/100+x%100/10+x%10;
  21. sum2=x1/100+x1%100/10+x1%10;
  22. if (sum1==sum2 && sum1+sum2==n)
  23. {
  24. k++;
  25. printf("\t%i\n",a[i]);
  26. }
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement