Advertisement
Guest User

Codice per Boyka22

a guest
Jul 17th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main(){
  7.  
  8.     // Dichiarazione
  9.     int vett[5];
  10.     int i = 0;
  11.  
  12.     // Inserimento valori
  13.     while(i < 5)
  14.     {
  15.         cout<<"Inserisci il valore " << (i + 1) << ": ";
  16.         cin>>vett[i];
  17.         i++;
  18.     }
  19.  
  20.     cout << "\nI valori che hai inserito sono: ";
  21.  
  22.     // Valori del vettore in ordine crescente.
  23.     for (i = 0; i < 5; i++){
  24.         if (i < 4) cout << vett[i] << " ";
  25.         else cout << vett[i];
  26.     }
  27.  
  28.     cout << "\nAl contrario i valori sono: ";
  29.  
  30.     // Valori del vettore in ordine decrescente.
  31.     for (i = 4; i >= 0; i--){
  32.         if (i > 0) cout << vett[i] << " ";
  33.         else cout << vett[i];
  34.     }
  35.  
  36.     cout << endl;
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement