Advertisement
Guest User

prova funzioni

a guest
Nov 28th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. double acquisisci()
  6. {
  7.     double x;
  8.     system("cls");
  9.     cout<<"Dato un numero, se è pari fa il quadrato altrimenti il cubo..."<<endl;
  10.     cout<<"Inserire un numero: ";
  11.     cin>>x;
  12.     return x;
  13. }
  14. double quadr(double x)
  15. {
  16.     x=x*x;
  17.     return x;
  18. }
  19. double cubo(double x)
  20. {
  21.     x=pow(x,3);
  22.     return x;
  23. }
  24. void visualizza(double x)
  25. {
  26.     cout<<"Risultato: ";
  27.     cout<<x;
  28. }
  29. int se(double i)
  30. {    
  31.     cin>>i;
  32.     return i;
  33. }
  34. int exit(double y)
  35. {
  36. }
  37. int main()
  38. {
  39.     int x,y,i;
  40.     while(1)
  41.     {
  42.         x=acquisisci();
  43.         if(x%2==0)
  44.         {
  45.             x=quadr(x);
  46.         }
  47.         else
  48.         {
  49.             x=cubo(x);
  50.         }
  51.         cout<<endl;
  52.         visualizza(x);
  53.         cout<<endl<<endl;
  54.         cout<<"Vuoi Continuare ?";
  55.         cout<<endl<<"[1]Si"<<endl<<"[2]No"<<endl;
  56.         cout<<endl;
  57.         cin>>i;
  58.         cout<<endl;
  59.         if(i==2)
  60.         {
  61.             system("pause");
  62.             return EXIT_SUCCESS;
  63.         }
  64.     }
  65.    
  66.     system("pause");
  67.     return EXIT_SUCCESS;
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement