vertc

06-03

Mar 6th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream> // dane: https://pastebin.com/06P6S4JH
  2. #include <fstream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main () {
  8.     ifstream dane("dane.txt");
  9.     ofstream wynik("wynik6.txt");
  10.     int a=0, dl, dl2;
  11.     string s1, s2;
  12.     while(!dane.eof()) {
  13.         dane>>s1;
  14.         dl = s1.size();
  15.         if(s1[0] == s1[dl-1]) {
  16.             a++;
  17.         }
  18.     }
  19.     dane.close();
  20.     wynik<<"a) Ilosc liczb spelniajacych warunek to: "<<a<<endl;
  21.  
  22.     ifstream dane2("dane.txt");
  23.     while(!dane2.eof()) {
  24.         dane2>>s2;
  25.     //  cout<<s2<<endl;
  26.         dl = s2.size();
  27.         if ((s2.size() == 3 && s2[0]<=s2[1] && s2[1]<=s2[2])
  28.         || (s2.size() == 4 && s2[0]<=s2[1] && s2[1]<=s2[2] && s2[2]<=s2[3])
  29.         || (s2.size() == 5 && s2[0]<=s2[1] && s2[1]<=s2[2] && s2[2]<=s2[3] && s2[3]<s2[4])
  30.         || (s2.size() == 6 && s2[0]<=s2[1] && s2[1]<=s2[2] && s2[2]<=s2[3] && s2[3]<s2[4] && s2[4]<s2[5])
  31.         || (s2.size() == 7 && s2[0]<=s2[1] && s2[1]<=s2[2] && s2[2]<=s2[3] && s2[3]<s2[4] && s2[4]<s2[5] && s2[5]<s2[6])) {
  32.             cout<<s2<<endl;
  33.         }  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment