Advertisement
a53

Magie

a53
Feb 2nd, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,nrcopii,nrmagic,nrmagicmax=0,an;
  7. ifstream f("magie.in");
  8. f>>n;
  9. for(int i=1;i<=n;++i)
  10. {
  11. f>>an;
  12. nrmagic=an%10+an%100/10+an%1000/100+an/1000;
  13. if(2017-an==12)
  14. ++nrcopii;
  15. if(nrmagic>nrmagicmax)
  16. nrmagicmax=nrmagic;
  17. }
  18. f.close();
  19. ofstream g("magie.out");
  20. g<<nrcopii<<'\n'<<nrmagicmax;
  21. g.close();
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement