Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<string.h>
  4. using namespace std;
  5.  
  6. string s;
  7.  
  8. int read_data()
  9. {
  10. fstream f;
  11. f.open("input.dat",ios::in);
  12. f>>s;
  13. f.close();
  14. }
  15.  
  16. int main()
  17. {
  18. read_data();
  19. int counter=0;
  20. while (s[counter]!='\0') { counter++; }
  21. int result=0;
  22. for(int i=0;i<counter;i++)
  23. {
  24. int value;
  25. if ((int)s[i]==48) value=0;
  26. if ((int)s[i]==49) value=1;
  27. if ((int)s[i]==50) value=2;
  28. result=result*10+value;
  29. }
  30. cout<<result;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement