5. #include <iostream>
#include <math.h>
#include <STdio.h>
#include <windows.h>
#include <string>
#define BG_BLACK (0) //0
#define FG_YELLOW (14) //FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY
using namespace std;
void clrscr()/*Creando funcion para limpiar pantalla.*/
{
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord = {0, 0};
DWORD count;
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hStdOut, &csbi);
FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
SetConsoleCursorPosition(hStdOut, coord);
}
void main()
{
//-----Fijando color de consola:
HANDLE hStdInput = INVALID_HANDLE_VALUE,
hStdOutput = INVALID_HANDLE_VALUE;
hStdInput = GetStdHandle(STD_INPUT_HANDLE);
hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdOutput,BG_BLACK | FG_YELLOW);
int x,y,z;
int impar=0;
int opt;
double contador1,contador2,contador3,suma1=0,suma2=0,suma3=0;
int salir,saliryesno;
salir=0;
while(salir==0){
clrscr();/*Llamando la funcion para limpiar pantalla.*/
cout<<"tttttMENU DE CALCULOSn";
cout<<"tttt========================nn";
cout<<"ttCATEGORIAtttttCODIGOnn";
cout<<"ttSUMA DE LOS PRIMEROS 30 NUMEROS POSITIVOS ...........1n";
cout<<"ttSUMA DE LOS PRIMEROS 50 NUMEROS IMPARES POSITIVOS....2n";
cout<<"ttSUMA DE LOS 20 NUMEROS PARES NEGATIVOS...............3n";
cout<<"ttINTRODUSCA EL CODIGO: ";
scanf("%d",&opt);
while((opt<1)||(opt>3))
{
cout<<"CODIGO INCORRECTO VUELVA A INGRESAR: ";
scanf("%d",&opt,"r");
}
cout<<"n";
switch(opt){
case 1:
cout<<"suma de los 30 primeros numeros positivos";
for(contador1=1;contador1<=30;contador1=contador1+1)
{
suma1=suma1+contador1;
cout<<suma1;
6. cout<<"n";
}
break;
case 2:
cout<<"Suma de los 50 primeros números impares enteros positivos";
for(contador2=0;contador2<=50;contador2++)
{
if(fmod(contador2,2)!=0){
impar++;
suma2=suma2+contador2;
cout<<suma2;
cout<<"n";
}
}
break;
case 3:
cout<<"Suma de los 20 primeros numeros pares enteros negativos";
for(contador3=0;contador3>=-20;contador3--)
{
if(fmod(contador3,2)==0){
par++;
suma3=suma3+contador3;
cout<<suma3;
cout<<"n";
}
}
break;
}
cout<<"n";
cout<<"PARA CONTINUAR CON OTRA OPERACION MARQUE 0 PARA SALIR MARUQE 1 :","r";
scanf("%d",&saliryesno);
if(saliryesno==1){
salir=1;
}
}
}
7. #include <iostream>
#include <math.h>
#include <STdio.h>
#include <windows.h>
#include <string>
#include <conio.h>
#define BG_BLACK (0) //0
#define FG_YELLOW (14) //FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY
using namespace std;
void clrscr()/*Creando funcion para limpiar pantalla.*/
{
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord = {0, 0};
DWORD count;
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hStdOut, &csbi);
FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count);
SetConsoleCursorPosition(hStdOut, coord);
}
void main()
{
//-----Fijando color de consola:
HANDLE hStdInput = INVALID_HANDLE_VALUE,
hStdOutput = INVALID_HANDLE_VALUE;
hStdInput = GetStdHandle(STD_INPUT_HANDLE);
hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdOutput,BG_BLACK | FG_YELLOW);
int x,y,z,a,b;
int impar=0;
int salir,saliryesno;
salir=0;
int res=0;
int contador;
while(salir==0){
clrscr();/*Llamando la funcion para limpiar pantalla.*/
cout<<"ingrese la cantidad de alumnos:";
cin>>b;
for(contador=1;contador<=b;contador++){
cout<<"n";
cout<<"ingrese la primera nota:";
cin>>x;
cout<<"ingrese la segunda nota:";
cin>>y;
cout<<"ingrese la tercera nota:";
cin>>z;
cout<<"ingrese la cuarta nota:";
cin>>a;
if(x>0 && x<=20){
if(x<y && x<z && x<a){
res=(y+z+a)/3;
cout<<"nel promedio es:n";
cout<<res;
}
}
else{cout<<"las notas deben ser mayor a 0 y menor a 20";
}
if(y>0 && y<=20){
8. if(y<x && y<z && y<a){
res=(x+z+a)/3;
cout<<"nel promedio es:n";
cout<<res;
}
}
else{cout<<"las notas deben ser mayor a 0 y menor a 20";
}
if(z>0 && z<=20){
if(z<y && z<x && z<a){
res=(y+x+a)/3;
cout<<"nel promedio es:n";
cout<<res;
}}
else{cout<<"las notas deben ser mayor a 0 y menor a 20";
}
if(a>0 && a<=20){
if(a<y && a<z && a<x){
res=(y+z+x)/3;
cout<<"nel promedio es:n";
cout<<res;
}
}
else{cout<<"las notas deben ser mayor a 0 y menor a 20";
}
}
cout<<"n";
cout<<"PARA CONTINUAR CON OTRA OPERACION MARQUE 0 PARA SALIR MARUQE 1 :","r";
scanf("%d",&saliryesno);
if(saliryesno==1){
salir=1;
}
}
}
9. # include <iostream>
# include <conio.h>
# include <ctype.h>
#include <STdio.h>
# include <math.h>
#include <windows.h>
using namespace std;
void main()
{
int R,max,min;
long int N,M,inv;
max=0; min=9;
cout<<"INGRESE UN NUMERO:";
cin>>N;
inv=0;
while (N>0) {
R=N%10;
inv=inv*10+R;
N=N/10;
if (R>max) {max=R;}
if (R<min) {min=R;}
}
cout<<"n EL MAYOR NUMERO ES:";
cout<<max;
cout<<"n EL MENOR NUMERO ES:";
cout<<min;
cin>>R;
}