Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int x,x1,n,s,i,a[999],sum1,sum2,k,k1;
- int main()
- {
- srand(time(NULL));
- printf("Enter s = ");
- scanf("%i",&s);
- printf("Enter n = ");
- scanf("%i",&n);
- k=0;
- for (i=0; i<s; i++)
- {
- a[i]=rand () % 89999;
- k1=rand() % 9 + 1;
- a[i]=k1*100000 + 99999-a[i];
- x=a[i]/1000;
- x1=a[i]%1000;
- sum1=x/100+x%100/10+x%10;
- sum2=x1/100+x1%100/10+x1%10;
- if (sum1==sum2 && sum1+sum2==n)
- {
- k++;
- printf("\t%i\n",a[i]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement