EVP4

#include<iostream>
using namespace std;

int main()
{
    int  i, n, suma, opcion,prod,factor, j;
    char resp[12];
do
      {
     cout<<endl;
     cout<<"************************************************\n";
    cout <<"MENU PRINCIPAL\n";  
     cout<<"1) NUMEROS ESCALONADOS \n";
     cout<<"2) SUMA DE CUBOS  \n";
     cout<<"3) SUMA DE LOS MULTIPLOS DE 4 \n";
     cout<<"4) MOSTRAR SI SON O NO MULTIPLOS DE 3 \n";
     cout<<"5) SUMA DE NUMEROS PARES  \n";
     cout<<"6) SUMA DE NUMEROS NATURALES  \n";
     cout<<"7) SUSECIONES \n";
     cout<<"8) DESCOMPONE NUMEROS EN FACTORES PRIMOS  \n";
     cout<<"9) SUMA DE NUMEROS DE 3 CIFRAS  \n";
     cout<<"                   DIGITE  <0> PARA SALIR\n";
     cout<<"************************************************\n";
     cout<<"INGRESE LA OPCION : "; cin>>opcion; cout<<" \n";

     switch(opcion)
         {
             case 1:
                 for(i = 1; i <= 20; i++)
  {
 for(j = 1; j <= i; j++)
  cout << j << " ";
 cout << endl;
  }
             case 2:
              {
                   suma=0;
     i = 1;
   cout<<endl;
    cout <<"CALCULO DE LA SUMA DE LOS PRIMEROS CUBOS";  
    cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR: ";
   cin >>n;
   cout<<endl;
    for (i=1; i<=n; i++)
    {
        suma = suma + (i*i*i);
    }
       cout <<  "LA SUMA DE LOS PRIMEROS CUBOS ES: "<< suma;
      cout<<endl;

                break;
               }
         case 3:
              {     suma=0;
     i = 1;
   cout<<endl;
    cout <<"CALCULO DE LA SUMA DE LOS PRIMEROS MULTIPLOS DE 4";  
    cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR: ";
   cin >>n;
   cout<<endl;
    for (i=1; i<=n; i++)
    {
        suma = suma + (4*i);
    }
       cout <<  "LA SUMA DE LOS PRIMEROS MULTIPLOS DE 4 ES: "<< suma;
      cout<<endl;
   
      break;
                   }
                   case 4:
                        { for(i = 1; i <= 20; i++)
  {
  cout << i;
  if(i % 3 == 0) cout << " es mUltiplo de 3";
  else cout << " no es multiplo de 3";
  cout << endl;
  }
break;
                        }
        case 5:
             {cout <<"CALCULO DE LA SUMA DE LOS NUMEROS PARES";  
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR:";  
cin >>n;
cout<<endl;
        suma=0;
        i = 1;
    while (i<=n)
    {
        suma = suma + (2*i);
        i= i + 1;
    }
       cout <<  "LA SUMA DE LOS NUMEROS PARES: "<< suma;
      cout<<endl;
break;
                        }
        case 6:
             {    cout <<"SUMATORIA DE NUMEROS NATURALES";  
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR:";  
cin >>n;
cout<<endl;
        suma=0;
        i = 1;
    while (i<=n)
    {
        suma = suma + (i);
        i= i + 1;
    }
       cout <<  "LA SUMA ES: "<< suma;
      cout<<endl;
break;
                        }
        case 7:
             {   
             i=1;
  bool sumar = true;
 bool terminado = false;

   do {
   cout << i;
             terminado = (i == 23);
             if(terminado) cout << "."; else cout << ", ";
             if(sumar) i += 4; else i -= 2;
              sumar = !sumar;
            } while(!terminado);
             cout << endl;
             break;
                        }
          case 8:
               { 
    do {
 cout << "Introduce un número entero: ";
 cin >> n;
 factor = 2;
 while(n >= factor*factor) {
 if(!(n % factor)) {
 cout << factor << " * ";
 n = n / factor;
 continue;
 }
 if(factor == 2) factor++;
 else factor += 2;
 }
 cout << n << endl;
 cout << "Descomponer otro número?: ";
 cin >> resp;
 }while(resp[0] == 's' || resp[0] == 'S');
break;
                        }
      case 9:
           {    cout <<"SUMATORIA DE NUMEROS DE 3 CIFRAS";  
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS";
     cout<<endl;
     cout<<"LA SUMA SE REALIZA DESDE 100 PARA ARRIBA:";
cin >>n;
cout<<endl;
   if (n<=999)
   {
        suma=0;
        i = 1;
    do
    {
        suma = suma+ 99+ i;
        i= i + 1;
    }
    while (i<=n);
       cout <<  "LA SUMA ES "<< suma;
      cout<<endl;
      }
      else
      {
           cout<<"INGRESE UN NUMERO ENTRE 1 Y 999";
           cout<<endl;
           }
break;
                        }                            
         }
        cout<<endl;

 }
  while (opcion != 0);        

        //system("pause");
        return 0;
  }

No hay comentarios:

Publicar un comentario