Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- string wyraz;
- char znak;
- int kod,kodl,a;
- bool wyraztest(string a)
- {
- for(int i=0;i<=a.length()-1;i++)
- {
- if(!isalpha(wyraz[i])) return false;
- }
- return true;
- }
- int main()
- {
- do
- {
- cout << "Podaj wyraz" << endl;
- cin>>wyraz;
- } while(!wyraztest(wyraz));
- do
- {
- cout<<"Podaj znak";
- cin>>znak;
- } while(!isalpha(znak));
- kod=znak;
- if(znak>=97) kodl=kod-32;
- else
- kodl=kod+32;
- int ileliter=0;
- for(int i=0;i<=wyraz.length()-1;i++)
- {
- a=wyraz[i];
- if(a==kod||a==kodl) ileliter++;
- }
- cout<<"liter:"<<znak<<"znaleziono;"<<ileliter;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement