avatar
Untitled

Guest 525 3rd Apr, 2023

CPP 2.11 KB
                                           
                         #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
Recent Pastes
Ta strona używa plików cookie w celu usprawnienia i ułatwienia dostępu do serwisu oraz prowadzenia danych statystycznych. Dalsze korzystanie z tej witryny oznacza akceptację tego stanu rzeczy.
Wykorzystywanie plików Cookie
Jak wyłączyć cookies?
ROZUMIEM