Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> // dane: https://pastebin.com/06P6S4JH
- #include <fstream>
- #include <cmath>
- using namespace std;
- int main () {
- ifstream dane("dane.txt");
- ofstream wynik("wynik6.txt");
- int a=0, dl, dl2;
- string s1, s2;
- while(!dane.eof()) {
- dane>>s1;
- dl = s1.size();
- if(s1[0] == s1[dl-1]) {
- a++;
- }
- }
- dane.close();
- wynik<<"a) Ilosc liczb spelniajacych warunek to: "<<a<<endl;
- ifstream dane2("dane.txt");
- while(!dane2.eof()) {
- dane2>>s2;
- // cout<<s2<<endl;
- dl = s2.size();
- if ((s2.size() == 3 && s2[0]<=s2[1] && s2[1]<=s2[2])
- || (s2.size() == 4 && s2[0]<=s2[1] && s2[1]<=s2[2] && s2[2]<=s2[3])
- || (s2.size() == 5 && s2[0]<=s2[1] && s2[1]<=s2[2] && s2[2]<=s2[3] && s2[3]<s2[4])
- || (s2.size() == 6 && s2[0]<=s2[1] && s2[1]<=s2[2] && s2[2]<=s2[3] && s2[3]<s2[4] && s2[4]<s2[5])
- || (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])) {
- cout<<s2<<endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment