Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. ifstream plik("plik.txt");
  8. int dlugosc=0;
  9. char ch;
  10. if(plik.good())
  11. {
  12. while(!plik.eof())
  13. {
  14. plik >> ch;
  15. dlugosc++;
  16. }
  17. }
  18. plik.close();
  19.  
  20. ifstream plik2("plik.txt");
  21. char * pobrane;
  22. pobrane = new char[dlugosc];
  23. int x=0;
  24. while(!plik2.eof())
  25. {
  26. plik2 >> pobrane[x];
  27. x++;
  28. }
  29.  
  30. for(int i=0; i<dlugosc; i++)
  31. {
  32. cout << i << pobrane[i] << endl;
  33. if(pobrane[i]=='0' || pobrane[i]=='1' || pobrane[i]=='2' || pobrane[i]=='3' || pobrane[i]=='4' || pobrane[i]=='5' || pobrane[i]=='6' || pobrane[i]=='7' || pobrane[i]=='8' || pobrane[i]=='9')
  34. {
  35. if(pobrane[i+1]=='o')
  36. {
  37. cout << "odejmowanie: " << pobrane[i]-pobrane[i+6] << endl;
  38. }
  39. }
  40. }
  41.  
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement