Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- int main()
- {
- int n,nrcopii,nrmagic,nrmagicmax=0,an;
- ifstream f("magie.in");
- f>>n;
- for(int i=1;i<=n;++i)
- {
- f>>an;
- nrmagic=an%10+an%100/10+an%1000/100+an/1000;
- if(2017-an==12)
- ++nrcopii;
- if(nrmagic>nrmagicmax)
- nrmagicmax=nrmagic;
- }
- f.close();
- ofstream g("magie.out");
- g<<nrcopii<<'\n'<<nrmagicmax;
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement