Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. cout << "Inserisci la dimensione dell'array che vuoi usare." << endl;
  8. const int dim = 100;
  9. int vet[dim];
  10. int n;
  11. int somma;
  12. do
  13. {
  14. cin >> n;
  15. if (n <= 1 || n >= 100)
  16. {
  17. cout << "Inserisci una dimensione tra 1 e 100."<<endl;
  18. }
  19. }
  20. while (n <= 1 || n >= dim);
  21. for (int i = 0; i<n; i++)
  22. {
  23. cout << "Indice " << i <<endl;
  24. cin >> vet[i];
  25. cout << "Hai inserito " << vet[i]<<endl;
  26. somma = somma + vet[i];
  27. }
  28. cout << "La somma dei vettori e': " << somma <<endl;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement