Advertisement
alexon5519

25-programare

Feb 26th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5.  
  6. int v[10];
  7. int main(){
  8. ifstream f1("atestat.in");
  9. ofstream f2("atestat.out");
  10. int64_t n,x;
  11. int s=0,maxim=0,i=0,y;
  12. f1>>n;
  13. x=n;
  14. while(x != 0){
  15. y=x%10;
  16. if(maxim < y)
  17. maxim=y;
  18. s=s+y;
  19. v[y]++;
  20. x=x/10;
  21. }
  22. f2<<s<<" "<<maxim<<endl;
  23. for(i=0;i<=maxim;i++)
  24. f2<<v[i]<<" ";
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement