Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- void asterischi (string a[],int l)
- {
- int i=0,j=0,m=0,k;
- while (i<l)
- {
- if ((a[i].length())>5)
- {
- m+=a[i].length();
- j++;
- }
- i++;
- }
- j=m/j;
- cout << "Valore di m: " << m << endl;
- cout << "il valore medio e' :" << j << endl;
- string b[j];
- i=0;
- string j_asterischi;
- while (i<j)
- {
- j_asterischi+=char('*');
- i++;
- }
- cout << "questo e' j_asterischi :" << j_asterischi<< "\n";
- i=0;
- while (i<j)
- {
- if (i==0)
- b[i]="";
- else
- {
- k=0;
- while (k<i)
- {
- b[i]+=j_asterischi;
- k++;
- }
- }
- i++;
- }
- i=0;
- while (i<j)
- {
- cout << "b[" << i << "]=" << b[i] << endl;
- i++;
- }
- }
- int main()
- {
- int h,i=0,j,k; // i variaibile contatore, j-> lunghezza a, k-> lunghezza b
- cout << "Inserire la grandezza dell'array A: ";
- cin >> j;
- string a[j];
- while (i<j)
- {
- h=0;
- while (h<=rand()%10+1)
- {
- a[i]+=rand()%26+int(char('a'));
- h++;
- }
- cout << a[i] << endl;
- i++;
- }
- asterischi (a,j);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement