Angelus331 / c-programcion-computacional

tareas y proyectos pa no olvidar
0 stars 0 forks source link

trabajos de clase #4

Open Angelus331 opened 1 month ago

Angelus331 commented 1 month ago

los trabajos que rescate

Angelus331 commented 1 month ago

include

include

using namespace std; int main() { float x,y,a; cout<<"ingrese x:"; cin>>x; a=(x+(xx))/((5x)+3); y=(a+x)((a)/(a+(2x))); cout<<"el valor de y es:"; cout<<y; return 0; }

Angelus331 commented 1 month ago

include

include

using namespace std; int main() { float x,y,a; cout<<"ingrese x:"; cin>>x; a=(x+(xx))/((5x)+3); y=(a+x)((a)/(a+(2x))); cout<<"el valor de y es:"; cout<<y; return 0; }

Angelus331 commented 1 month ago

include

include

using namespace std; int main() { float x,y,z,a,b,c,A; cin>>x; cin>>y; cin>>z; a=(((2x)+y)/z); b=((yyy)-z); c=(x+(2y)+(3z))/(z-(2y)-(3x)); A=((ab)/(c+(xx)+(zz))); cout<<fixed<<setprecision(6)<<"el valor de y sera "<<A; return 0; }

Angelus331 commented 1 month ago

include

include // Para usar rand() y srand()

include // Para usar time()

using namespace std;

int main() // Llamadas telefonicas { int v; cout<<"Vamos a jugar"<<endl; cout<<"Piedra = 1"<<endl; cout<<"Papel = 2"<<endl; cout<<"Tijera = 3"<<endl; cin >> v; srand(time(0)); int computadora; computadora = rand() % 3 + 1; switch(v) { case 1: cout<<"El humano eligio piedra"<<endl; break; case 2: cout<<"El humano eligio papel"<<endl; break; case 3: cout<<"El humano eligio tijera"<<endl; break; }

switch(computadora)
{
    case 1: cout<<"La computadora eligio piedra"<<endl;
            if(v==2)
            {
                cout<<"Gana el humano";
            }
            if(v==3)
            {
                cout<<"Gana la computadora";
            }
            if(v==1)
            {
                cout<<"Empate";
            }
            break;
    case 2: cout<<"La computadora eligio papel"<<endl;
            if(v==1)
            {
                cout<<"Gana la computadora";
            }
            if(v==2)
            {
                cout<<"Empate";
            }
            if(v==3)
            {
                cout<<"Gana el humano";
            }
            break;
    case 3: cout<<"La computadora eligio tijera"<<endl;
            if(v==1)
            {
                cout<<"Gana el humano";
            }
            if(v==2)
            {
                cout<<"Gana la computadora";
            }
            if(v==3)
            {
                cout<<"Empate";
            }
            break;
}
return 0;

}

Angelus331 commented 1 month ago

include

include

include

using namespace std; int main() { srand(time(0)); int eleccion; cout<<"SELECCIONE:"<<endl<<"(1) piedra"<<endl<<"(2) papel"<<endl<<"(3) tijera"<<endl; cin>>eleccion;

int computadora;
computadora = rand() % 3 + 1;
cout<<"la eleccion de la computadora fue: "<<computadora<<endl;

if(eleccion==computadora) {
    cout<<"empate!"<<endl;}
    else if ((eleccion==1 && computadora==3) || (eleccion==2 && computadora==1) || (eleccion==3 && computadora==2)) {
        cout<<"ganaste!"<<endl;
    }
    else {
    cout<<"la computadora gana";}

return 0;

}

Angelus331 commented 1 month ago

include

include

using namespace std; int main() { float A,B; float x; cin>> A; cin>> B; x = pow(AA+BB,1/2); cout<<"en total es "; cout<<x; return 0; }

Angelus331 commented 1 month ago

include

using namespace std; int main() { float a,b,c,d,e,f; float promedio; cin>> a; cin>> b; cin>> c; cin>> d; cin>> e; cin>> f; promedio=(a+b+c+d+e+f)/6; cout<<"el area es "; cout<<promedio; return 0; }

Angelus331 commented 1 month ago

include

include

using namespace std; int main() { float a,b,c,y,x1,x2; cin>>a>>b>>c; y=(bb)-(4ac); x1=(-b+sqrt(y))/2a; x2=(-b-sqrt(y))/2*a; cout<<x1<<endl; cout<<x2; return 0; }

Angelus331 commented 1 month ago

// Online C++ compiler to run C++ program online

include

using namespace std; int main() { int x; cin>>x; int suma=0; while(2<=x) { suma=suma+x; x=x-2; } cout<<"suma total "<<suma; return 0; }

Angelus331 commented 1 month ago

// Online C++ compiler to run C++ program online

include

using namespace std; int main() { int n; cout<<"me ayudas"; cin>>n; int suma=0; for(int i=2; i<=n ; i=i+2) { suma=suma+i;

 if(n==i){
     cout<<i;
 }
 else{
     cout<<i<<"+";
 }
}
cout<<endl;
 cout<<"en total es "<<suma;
return 0;

}

Angelus331 commented 1 month ago

include

include

using namespace std; int main() { float x,y,z,a,b,c,A; cout<<"ingresa el valor de x: "; cin>>x; cout<<"ingresa el valor de y: "; cin>>y; cout<<"ingresa el valor de z: "; cin>>z; a=(((2x)+y)/z); b=((yyy)-z); c=(x+(2y)+(3z))/(z-(2y)-(3x)); A=((ab)/(c+(xx)+(zz))); cout<<fixed<<setprecision(6)<<"el valor de y sera "<<A; return 0; }

Angelus331 commented 1 month ago

include

include

using namespace std; int main() { float a,b,c,y,x1,x2; cin>>a>>b>>c; y=(bb)-(4ac); x1=(-b+sqrt(y))/2a; x2=(-b-sqrt(y))/2*a; cout<<x1<<endl; cout<<x2; return 0; }

Angelus331 commented 1 month ago

include

using namespace std; int main() { float a,b,c,d,e,f; float promedio; cin>> a; cin>> b; cin>> c; cin>> d; cin>> e; cin>> f; promedio=(a+b+c+d+e+f)/6; cout<<"el area es "; cout<<promedio; return 0; }

Angelus331 commented 1 month ago

include

include

using namespace std; int main() { float A,B; float x; cin>> A; cin>> B; x = pow((AA)+(BB),1.0/2); cout<<"en total es "; cout<<x; return 0; }

Angelus331 commented 1 month ago

include

using namespace std; int main() { int i,j,n; cin>>n; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ cout<<" "; } if(1<n){ cout<<" "<<endl; } } return 0; }

Angelus331 commented 1 month ago

include

using namespace std;

int main() { int i, n; cout << "ingrese n: "; cin >> n; for (int i = 1; i <= n; i++) { cout << i << endl; } return 0; }

Angelus331 commented 1 month ago

include

using namespace std;

int main() { int i, n; cout << "ingrese n: "; cin >> n;

for (int i = 2; i <= n; i++) {
    cout << i << endl;
}

return 0;

}

Angelus331 commented 1 month ago

include

define PI 3.1416

int main() { float area_circulo(float radio) { return PI radio radio; }

float area_triangulo(float base, float altura) {
    return (base * altura) / 2;
}

printf("El area del circulo es: %f\n", area_circulo(5));
printf("El area del triangulo es: %f", area_triangulo(5, 10));

return 0;

}

Angelus331 commented 1 month ago

include

using namespace std;

int main() { int A[5], i; cout << "Ingrese los valores: "; for(i=0; i<5; i++) cin >> A[i];

if(A[0] > 0)
    if(A[1] > 0)
        cout << "\nA[0] y A[1] son mayores que 0";
    else
        cout << "\nA[1] no es mayor que 0";
else
    cout << "\nA[0] no es mayor que 0";

return 0;

}

Angelus331 commented 1 month ago

include

using namespace std;

// function to convert celsius to fahrenheit double c_to_f(double c) { double f; // formula for conversion f = (c * 9/5) + 32; return f; }

int main() { double celsius, fahrenheit;

cout << "temperatura en Celsius: ";
cin >> celsius;

fahrenheit = c_to_f(celsius);

cout << "Temperatura en Fahrenheit es: " << fahrenheit << endl;

return 0;

}

Angelus331 commented 1 month ago

include

using namespace std;

int main() { int T; cout << "Ingrese un número: "; cin >> T;

switch (T) {
    case 1:
        cout << "Uno" << endl;
        break;
    case 2:
        cout << "Dos" << endl;
        break;
    default:
        cout << "Número no reconocido" << endl;
        break;
}

return 0;

}

Angelus331 commented 1 month ago

SUMATORIA DE NUMEROS NATURALES

include

using namespace std; int main() { int n; int a=0; cin>>n; for (int i =1; i<=n;i++){ a=a+i; } cout<<a; return 0; }

Angelus331 commented 1 month ago

include

using namespace std; int main() { int n; int a=0; cin>>n; for (int i =1; i<=n;i++){ a=a+(2*i+5); } cout<<a; return 0; }

Angelus331 commented 1 month ago

include

using namespace std; int main() { int n; int a=0; cin>>n; for (int i =1; i<=n;i++){

a=a+(i+2)+(i+3)+(i+4); } cout<<a; return 0; }

Angelus331 commented 1 month ago

include

using namespace std; int main() { int n; int a=1; cin>>n; for (int i =1; i<=n;i++){ a=a*i; } cout<<a; return 0; }