Untitled
Guest 1,136 3rd Apr, 2023
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
using namespace std;
bool pal(string n)
{
for(int i=1;i<n.length()/2;i++)
{
if(n[i]!=n[n.length()-i])
{
return false;
}
}
return true;
}
bool pal2(string n)
{
for(int i=0;i<n.length()/2;i++)
{
if(n[i]!=n[n.length()-i-2])
{
return false;
}
}
return true;
}
int main()
{
cout << "zad 1" << endl;
string l;
int max=0;
ifstream in("napisy.txt");
for(int i=0;i<1000;i++)
{
in >> l;
for(int j=0;j<50;j++)
{
if(l[j]<='9')
{
max++;
}
}
}
in.close();
cout << max << endl;
cout << endl;
cout << "zad 2" << endl;
string f;
int kol=0;
ifstream in2("napisy.txt");
for(int i=1;i<1001;i++)
{
in2 >> f;
if(i%20==0)
{
cout << f[kol];
kol++;
}
}
in2.close();
cout << endl << endl;
string h;
cout << "zad 3" << endl;
ifstream in3("napisy.txt");
for(int i=0;i<1000;i++)
{
in3 >> h;
if(pal(h)==true or pal2(h)==true)
{
if(pal2(h)==true)
{
cout << h[24];
}
else
{
cout << h[25];
}
}
}
cout << endl;
in3.close();
cout << endl;
cout << "zad 4" << endl;
int g=0;
string temp;
string b;
int v=0;
bool po=true;
ifstream in4("napisy.txt");
for(int i=0;i<1000;i++)
{
in4 >> b;
for(int j=0;j<50;j++)
{
if(b[j]<='9')
{
g=g*10+(b[j]-48);
if(g>10 and g<65)
{
g=0;
}
else if (g>10 and (po))
{
temp[v]=g;
cout << temp[v];
g=0;
if((temp[v]=='X') and (temp[v-1]=='X' )and (temp[v-2]=='X'))
{
po=false;
}
v++;
}
}
}
g=0;
}
in4.close();
return 0;
}
To share this paste please copy this url and send to your friends
RAW Paste Data