Advertisement
a53

caraghios

a53
Nov 13th, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream f("caraghios.in");
  4. ofstream g("caraghios.out");
  5. int nr; /// Memoreaza solutia
  6.  
  7. int main()
  8. {
  9. char c,cc; /// c=primul caracter citit, cc=caracterul curent citit
  10. f>>c;
  11. if(c=='1') /// Daca o cifra este 1, conditia 1=1*1 e adevarata
  12. ++nr;
  13. while(f>>cc)
  14. {
  15. if(cc=='1')
  16. {
  17. ++nr;
  18. if(c=='8') /// Daca cifra anterioara e 8 si cea curenta e 1, atuncii conditia 81=(8+1)*8+1) e adevarata
  19. ++nr;
  20. }
  21. c=cc;
  22. }
  23. g<<nr;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement