Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #include <fstream>
- using namespace std;
- int main() {
- int a, b, c, ilosc=0, wartosc, iloscw=0, max=0;
- string d, e, f;
- ifstream liczby("liczby.txt");
- while(!liczby.eof()) { // podpunkt a
- liczby>>a;
- liczby>>b;
- liczby>>c;
- if(c>b && b>a) {
- ilosc++;
- }
- }
- ifstream liczby2("liczby.txt");
- while(!liczby2.eof()) { // podpunkt c
- liczby2>>d;
- liczby2>>e;
- liczby2>>f;
- wartosc=0;
- for (int i=0;i<d.length();i++) {
- wartosc = wartosc + (d[i]-48);
- }
- for (int i=0;i<e.length();i++) {
- wartosc = wartosc + (e[i]-48);
- }
- for (int i=0;i<f.length();i++) {
- wartosc = wartosc + (f[i]-48);
- }
- if(wartosc==35) {
- iloscw++;
- }
- if(wartosc>max) {
- max = wartosc;
- }
- }
- cout<<"Ilosc par liczb spelniajacych warunek: "<<ilosc<<endl;
- cout<<"Ilosc wierszy, ktorych suma cyfr wynosi 35 to: "<<iloscw<<endl;
- cout<<"Najwieksza suma cyfr w wierszu to: "<<max;
- }
Advertisement
Add Comment
Please, Sign In to add comment