Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- string Genera(int intero)
- {
- int i=0;
- string vocale;
- // bool moneta;
- while (i<intero)
- {
- if (rand()%2) // se esce testa allora -> a , o; se esce croce allora -> e , i , u
- {
- if (rand()%2) // 'a' oppure 'o'
- vocale+='a';
- else
- vocale+='o';
- }
- else
- switch(rand()%3) // 'e' oppure 'i' oppure 'u'
- {
- case 0:
- vocale+='e';
- break;
- case 1:
- vocale+='i';
- break;
- case 2:
- vocale+='u';
- break;
- }
- i++;
- }
- return (vocale);
- }
- int main()
- {
- int lanci;
- cout << "Dimmi quante volte lanciare la moneta :";
- cin >> lanci;
- cout << "Questa e' la stringa generata : " << Genera(lanci);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement