vertc

29-05

May 29th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10.     int a, b, c, ilosc=0, wartosc, iloscw=0, max=0;
  11.     string d, e, f;
  12.     ifstream liczby("liczby.txt");
  13.     while(!liczby.eof()) { // podpunkt a
  14.         liczby>>a;
  15.         liczby>>b;
  16.         liczby>>c;
  17.         if(c>b && b>a) {
  18.             ilosc++;
  19.         }
  20.     }
  21.     ifstream liczby2("liczby.txt");
  22.     while(!liczby2.eof()) { // podpunkt c
  23.         liczby2>>d;
  24.         liczby2>>e;
  25.         liczby2>>f;
  26.         wartosc=0;
  27.         for (int i=0;i<d.length();i++) {
  28.             wartosc = wartosc + (d[i]-48);
  29.         }
  30.         for (int i=0;i<e.length();i++) {
  31.             wartosc = wartosc + (e[i]-48);
  32.         }
  33.         for (int i=0;i<f.length();i++) {
  34.             wartosc = wartosc + (f[i]-48);
  35.         }
  36.         if(wartosc==35) {
  37.             iloscw++;
  38.         }
  39.         if(wartosc>max) {
  40.             max = wartosc;
  41.         }
  42.     }
  43.     cout<<"Ilosc par liczb spelniajacych warunek: "<<ilosc<<endl;
  44.     cout<<"Ilosc wierszy, ktorych suma cyfr wynosi 35 to: "<<iloscw<<endl;
  45.     cout<<"Najwieksza suma cyfr w wierszu to: "<<max;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment