Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream fin("control1.in");
- ofstream fout("control1.out");
- int a,b,c,s,i,cs;int z, k;
- int main()
- {
- fin>>a>>b>>c;
- for(i=a;i<=b;i++)
- {
- s=0;
- z=i;
- while(z)
- {
- s=s+z%10;
- z=z/10;
- }
- if(s>=10)
- {
- cs=0;
- while(s)
- {
- cs=cs+s%10;
- s=s/10;
- }
- if(cs==c)
- k++;
- }
- else if(s==c)
- k++;
- }
- fout<<k;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement