Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream wej;
- wej.open("slowa.txt");
- ofstream wyj1;
- ofstream wyj2;
- ofstream wyj3;
- wyj3.open("wynik_4_3.txt");
- string slowo;
- int zera=0;
- int jedynki = 0;
- int ilosc = 0;
- int dl = 0;
- int x = 0;
- int il = 0;
- int suma = 0;
- int maxi = 0;
- int seria = 0;
- for(int i=0; i<1000; i++)
- {
- wej>>slowo;
- dl = slowo.length();
- jedynki = 0;
- zera = 0;
- x = 0;
- suma = 0;
- for(int y=0; y<dl; y++)
- {
- suma+=(slowo[y]-48);
- }
- if(slowo[0] == 48 && suma > 0)
- {
- while(x<dl)
- {
- if(slowo[x] == 49)
- {
- break;
- }
- else
- {
- x++;
- continue;
- }
- }
- while(x<dl)
- {
- if(slowo[x] != 49)
- {
- break;
- }
- else
- {
- if(x == dl-1)
- {
- il++;
- break;
- }
- else
- {
- x++;
- continue;
- }
- }
- }
- }
- for(int j=0; j<dl; j++)
- {
- if(slowo[j] == 48)
- {
- zera++;
- }
- else
- {
- jedynki++;
- }
- }
- if(zera>jedynki)
- {
- ilosc++;
- }
- for(int q=0;q<dl;q++){
- seria = 0;
- while(slowo[q] == 48){
- seria++;
- q++;
- }
- if(seria == 10){
- wyj3<<slowo<<endl;
- }
- if(seria>maxi){
- swap(maxi,seria);
- }
- }
- }
- wyj1.open("wynik_4_1.txt");
- wyj1<<ilosc;
- wyj1.close();
- wyj2.open("wynik_4_2.txt");
- wyj2<<il;
- wyj2.close();
- wyj3<<"Nadluzsza seria to: "<<maxi;
- wyj3.close();
- cout<<"Done";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement