Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cctype>
- #include <limits>
- using namespace std;
- int main()
- {
- char literyM[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
- char literyD[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
- int wystapieniaM[26]={0};
- int wystapieniaD[26]={0};
- int n;
- string tekst;
- cout<<"Prosze podac liczbe wierszy tekstu:"<<endl;
- cin>>n;
- cin.ignore( numeric_limits < streamsize >::max(), '\n' );
- if (n>150)
- {
- cout<<"Liczba wierszy tekstu nie moze przekraczac 150 wierszy"<<endl;
- main();
- }
- for (int z=0;z<n;z++)
- {
- cout<<"Prosze podac tekst do zliczenia liter:"<<endl;
- getline(cin,tekst);
- int dlugosc = tekst.length();
- for (int i=0; i<=dlugosc;i++)
- {
- if (islower(tekst[i]))
- {
- for (int m=0;m<=26;m++)
- {
- if (tekst[i] == literyM[m])
- {
- wystapieniaM[m]++;
- }
- }
- }
- if (isupper(tekst[i]))
- {
- for (int d=0;d<=26;d++)
- {
- if (tekst[i] == literyD[d])
- {
- wystapieniaD[d]++;
- }
- }
- }
- }
- }
- for (int wM=0;wM<26;wM++)
- {
- if (wystapieniaM[wM] > 0)
- {
- cout<<literyM[wM]<<" "<<wystapieniaM[wM]<<endl;
- }
- }
- for (int wD=0;wD<26;wD++)
- {
- if (wystapieniaD[wD] > 0)
- {
- cout<<literyD[wD]<<" "<<wystapieniaD[wD]<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement