Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <time.h>
- using namespace std;
- template <typename fib>
- fib FibNum(int m, fib a, fib b) {
- if (m==0){return a;}
- if (m==1){return b;}
- return FibNum(m-1, a, b) + FibNum(m-2, a, b);
- }
- int main() {
- string fibby = FibNum(15,string("b"),string("a"));
- std::sort(fibby.begin(), fibby.end());
- cout<<fibby<<endl<<endl;
- string gibberish;
- cout<<"Podaj litery: ";
- cin>>gibberish;
- std::sort(gibberish.begin(), gibberish.end());
- cout<<gibberish<<endl<<endl;
- int counta = 0;
- int countb = 0;
- for (int i = 0; i < fibby.size(); i++)
- {
- if (fibby[i] == 'a') counta++;
- if (fibby[i] == 'b') countb++;
- }
- cout<<"W slowie Fibonacciego, litera 'a' wystepuje "<<counta<<" razy."<<endl;
- cout<<"W slowie Fibonacciego, litera 'b' wystepuje "<<countb<<" razy."<<endl<<endl;
- int counta2 = 0;
- int countb2 = 0;
- for (int i = 0; i < gibberish.size(); i++)
- {
- if (gibberish[i] == 'a') counta2++;
- if (gibberish[i] == 'b') countb2++;
- }
- cout<<"W Twoim ciagu, litera 'a' wystepuje "<<counta2<<" razy."<<endl;
- cout<<"W Twoim ciagu, litera 'b' wystepuje "<<countb2<<" razy."<<endl<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement