Untitled
Kacper 1,249 3rd Apr, 2023
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
string s;
ifstream plik("mecz.txt");
plik >>s;
int l = 0;
for(int i = 0; i<s.size()-1; i++)
{
if(s[i] != s[i+1])
l++;
}
cout << "zad 1: " << l << endl;
int a=0,b=0;
for(int i=0; i<s.size(); i++)
{
if(s[i]=='A')
a++;
else
b++;
if(a >= 1000 and a >=b +3)
{
cout << "zad 2: A" << a << ":" << b << endl;
break;
}
else if(b >= 1000 and b >=a +3)
{
cout << "zad 2: B" << b << ":" << a << endl;
break;
}
}
int passa=0;
int lpass=0;
int pmax=0;
char d;
for(int i=0; i<s.size()-1; i++)
{
if(s[i]==s[i+1])
passa++;
else
{
if(passa >= 10)
lpass++;
if(passa > pmax)
{
pmax = passa;
d = s[i];
}
passa = 1;
}
}
cout << " zad 3: " << lpass << " " << d << " " << pmax << endl;
return 0;
}
To share this paste please copy this url and send to your friends
RAW Paste Data