Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- int v[20];
- int main(){
- int n,x,m=0,s,y,i=0;
- ifstream f1("atestat.in");
- ofstream f2("atestat.out");
- f1>>n;
- while(f1>>x){
- y=x;
- s=0;
- i++;
- v[i]=y;
- while(y != 0){
- s=s+y%10;
- y=y/10;
- }
- f2<<s<<" ";
- if(m == 0)
- m=s;
- if(m < s)
- m=s;
- }
- f2<<endl;
- for(i=1;i<=n;i++){
- y=v[i];
- s=0;
- while(y != 0){
- s=s+y%10;
- y=y/10;
- }
- if(m == s)
- f2<<v[i]<<" ";
- }
- f2.close();
- f1.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement