Zadanie 6 - Julian Wie IIIc
Guest 1,279 27th Sep, 2022
/*
zlozonosci:
m - liczba napisow
n - dlugosc napisu
6.1 - O(m*n)
6.2 - O(m*n)
6.3 - O(n)
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
int tab[11];
int najw[11];
string najwieksze[11];
bool czyAnty(string w, int n){
int i = 0;
bool czy=true;
while(i<n/2){
if(w[i]!=w[n-i-1])
czy=true;
else
return false;
i++;
}
return true;
}
int main(){
cout<<"Zadanie 6.3 :"<<endl;
ifstream plik;
plik.open("dane6.txt");
string w="";
int liczba=0;
while(plik >> w){
int maks=0, suma=0;
for(int i=0; i<100; i++){
maks=max(maks, int(w[i])-47);
suma+=int(w[i])-48;
}
tab[maks]++;
if(suma>najw[maks]){
najw[maks]=suma;
najwieksze[maks]=w;
}
if(czyAnty(w, 100)){
cout<<w<<endl;
liczba++;
}
}
cout<<liczba<<endl;
cout<<endl<<"Zadanie 6.2 :"<<endl;
for(int i=1; i<=10; i++){
if(najwieksze[i]=="")
continue;
cout<<i<<' '<<najwieksze[i]<<endl;
}
cout<<endl<<"Zadanie 6.1 :"<<endl;
for(int i=1; i<=10; i++){
if(tab[i]==0)
continue;
cout<<i<<' '<<tab[i]<<endl;
}
return 0;
}
To share this paste please copy this url and send to your friends
RAW Paste Data
Recent Pastes
- pastee
Markup | 3 | 5 minutes ago
- Untitled
Markup | 2 | 7 minutes ago
- Untitled
Markup | 3 | 8 minutes ago
- Always favorable prices for services such assensual massag in New Yourk
Java | 4 | 3 hours ago
- Untitled
Markup | 7 | 10 hours ago
- bakus
Python | 7 | 10 hours ago
- brak balansu
Markup | 8 | 11 hours ago