#include <stdio.h>
#include <iostream>
#include <windows.h>
using namespace std;
void captura();
void imprimir();
void imprimir1();
void gotoxy(int x,int y){
HANDLE hcon;
hcon=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwpos;
dwpos.X=x;
dwpos.Y=y;
SetConsoleCursorPosition(hcon,dwpos);
}
int matriz[3][4], x=5,y=8;
int main(){
captura();
imprimir();
imprimir1();
return 0;
}
void captura(){
for(int i=0; i<=2; i++){
for(int j=0; j<=3; j++){
gotoxy(y,x);
cin>>matriz[i][j];
x+=5;
}
y+=2;
x=5;
}
system("pause");
system("cls");
}
void imprimir(){
for(int i=0; i<=2; i++){
for(int j=0; j<=3; j++){
gotoxy(y,x);
cout<<matriz[i][j];
x+=5;
}
y+=2;
x=5;
}
system("pause");
system("cls");
}
void imprimir1(){
for(int i=0; i<=2; i++){
for(int j=0; j<=3; j++){
gotoxy(x,y);
cout<<matriz[i][j];
x+=5;
}
y+=2;
x=5;
}
system("pause");
system("cls");
}
Prueba del funcionamiento:
viernes, 18 de octubre de 2019
Matriz 4:
#include <stdio.h>
#include <iostream>
#include <windows.h>
using namespace std;
void captura();
void imprimir();
void gotoxy(int x,int y){
HANDLE hcon;
hcon=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwpos;
dwpos.X=x;
dwpos.Y=y;
SetConsoleCursorPosition(hcon,dwpos);
}
int matriz[4][4], x=5,y=8;
int main(){
captura();
imprimir();
system("pause");
return 0;
}
void captura(){
for(int i=0; i<=3; i++){
for(int j=0; j<=3; j++){
cout<<"Ingrese la calificacion:"<<endl;
cin>>matriz[i][j];
}
}
system("cls");
}
void imprimir(){
for(int i=0; i<=3; i++){
for(int j=0; j<=3; j++){
gotoxy(x,y);
cout<<matriz[i][j];
x+=5;
}
y+=2;
x=5;
}
}
Matriz 3:
#include <stdio.h>
#include <iostream>
#include <windows.h>
using namespace std;
void captura();
void imprimir();
void gotoxy(int x,int y){
HANDLE hcon;
hcon=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwpos;
dwpos.X=x;
dwpos.Y=y;
SetConsoleCursorPosition(hcon,dwpos);
}
int matriz[6][6], x=5,y=8;
int main(){
captura();
imprimir();
system("pause");
return 0;
}
void captura(){
for(int i=0; i<=5; i++){
for(int j=0; j<=5; j++){
cout<<"Ingrese la calificacion:"<<endl;
cin>>matriz[i][j];
}
}
system("cls");
}
void imprimir(){
for(int i=0; i<=5; i++){
for(int j=0; j<=5; j++){
gotoxy(x,y);
cout<<matriz[i][j];
x+=5;
}
y+=2;
x=5;
}
}
Prueba del funcionamiento:
#include <iostream>
#include <windows.h>
using namespace std;
void captura();
void imprimir();
void gotoxy(int x,int y){
HANDLE hcon;
hcon=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwpos;
dwpos.X=x;
dwpos.Y=y;
SetConsoleCursorPosition(hcon,dwpos);
}
int matriz[6][6], x=5,y=8;
int main(){
captura();
imprimir();
system("pause");
return 0;
}
void captura(){
for(int i=0; i<=5; i++){
for(int j=0; j<=5; j++){
cout<<"Ingrese la calificacion:"<<endl;
cin>>matriz[i][j];
}
}
system("cls");
}
void imprimir(){
for(int i=0; i<=5; i++){
for(int j=0; j<=5; j++){
gotoxy(x,y);
cout<<matriz[i][j];
x+=5;
}
y+=2;
x=5;
}
}
Prueba del funcionamiento:
Matriz 2:
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n,m,A [4][4],x=5,y=8,i;
void gotoxy (int x, int y){
HANDLE hcon;
hcon=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwPos;
dwPos.X= x;
dwPos. Y= y;
SetConsoleCursorPosition(hcon, dwPos);
}
int main (){
for(int i=0; i<=3; i++){
for (int j=0;j<3; j++){
gotoxy (x,y);
cin>>A[i][j];
x+=5;
}
y+=2;
x=5;
}
system ("color 4");
cout<<"NO";
return 0;
}
Prueba del funcionamiento:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n,m,A [4][4],x=5,y=8,i;
void gotoxy (int x, int y){
HANDLE hcon;
hcon=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwPos;
dwPos.X= x;
dwPos. Y= y;
SetConsoleCursorPosition(hcon, dwPos);
}
int main (){
for(int i=0; i<=3; i++){
for (int j=0;j<3; j++){
gotoxy (x,y);
cin>>A[i][j];
x+=5;
}
y+=2;
x=5;
}
system ("color 4");
cout<<"NO";
return 0;
}
Prueba del funcionamiento:
Matriz 1:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
void captura();
void imprime();
int mat[5][5];
int main(){
captura();
imprime();
system("pause");
return 0;
}
void captura(){
for(int i=0; i<=4; i++){
for(int j=0; j<=4; j++){
cout<<"Captura un numero:";
cin>>mat[i][j];
}
}
}
void imprime(){
for(int i=0; i<=4; i++){
for(int j=0; j<=4; j++){
cout<<"El numero en la posicion "<<i<<j<<" es"<<mat[i][j]<<endl;
}
}
}
Prueba del Funcionamiento:
#include <stdlib.h>
#include <iostream>
using namespace std;
void captura();
void imprime();
int mat[5][5];
int main(){
captura();
imprime();
system("pause");
return 0;
}
void captura(){
for(int i=0; i<=4; i++){
for(int j=0; j<=4; j++){
cout<<"Captura un numero:";
cin>>mat[i][j];
}
}
}
void imprime(){
for(int i=0; i<=4; i++){
for(int j=0; j<=4; j++){
cout<<"El numero en la posicion "<<i<<j<<" es"<<mat[i][j]<<endl;
}
}
}
Prueba del Funcionamiento:
Ejercicio 12:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
int v1[30], v2[30], n, a, b;
int main (){
for(int j=0;j<=29;j++){
n=rand()/100;
}
cout<<"ingresa un numero en el siguiente rango : (10 - 99)"<<endl;
cin>>a;
for (int j=1;j<=29;j++){
if(a=v1[j]);
b++;
}
cout<<"el numero esta en la posicion"<<b<<endl;
for(int j=0;j<=29;j++){
cout<<v1[j]<<j<<endl;
}
cout<<"el numero esta en la posicion"<<b<<endl;
for (int j=0;j<=29;j++){
cout<<v2[j]<<j<<endl;
}
system("PAUSE");
return 0;
}
Pruebas del Funcionamiento:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
int v1[30], v2[30], n, a, b;
int main (){
for(int j=0;j<=29;j++){
n=rand()/100;
}
cout<<"ingresa un numero en el siguiente rango : (10 - 99)"<<endl;
cin>>a;
for (int j=1;j<=29;j++){
if(a=v1[j]);
b++;
}
cout<<"el numero esta en la posicion"<<b<<endl;
for(int j=0;j<=29;j++){
cout<<v1[j]<<j<<endl;
}
cout<<"el numero esta en la posicion"<<b<<endl;
for (int j=0;j<=29;j++){
cout<<v2[j]<<j<<endl;
}
system("PAUSE");
return 0;
}
Pruebas del Funcionamiento:
Ejericio 11:
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int v1[15], v2[15], num1=15, num2;
int main(){
int n;
srand(time(NULL));
for(int i=0; i<=14; i++){
n=rand()/100;
v1[i]=n;
v2[i]=v1[i];
}
for(int i=0; i<num1; i++){
for(int j=0; j<num1-1; j++){
if (v2[j]>v2[j+1]){
num2=v2[j];
v2[j]=v2[j+1];
v2[j+1]=num2;
}
}
}
cout<<"Vector 1"<<endl;
for (int i=0; i<=14; i++){
cout<<v1[i]<<endl;
}
cout<<endl;
cout<<"Vector 2"<<endl;
for(int i=0; i<=14; i++){
cout<<v2[i]<<endl;
}
system("pause");
return 0;
}
Pruebas del funcionamiento:
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int v1[15], v2[15], num1=15, num2;
int main(){
int n;
srand(time(NULL));
for(int i=0; i<=14; i++){
n=rand()/100;
v1[i]=n;
v2[i]=v1[i];
}
for(int i=0; i<num1; i++){
for(int j=0; j<num1-1; j++){
if (v2[j]>v2[j+1]){
num2=v2[j];
v2[j]=v2[j+1];
v2[j+1]=num2;
}
}
}
cout<<"Vector 1"<<endl;
for (int i=0; i<=14; i++){
cout<<v1[i]<<endl;
}
cout<<endl;
cout<<"Vector 2"<<endl;
for(int i=0; i<=14; i++){
cout<<v2[i]<<endl;
}
system("pause");
return 0;
}
Pruebas del funcionamiento:
Ejericio 10:
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int v1[20], v2[20], n;
int main(){
srand(time(NULL));
for(int i=0; i<=19; i++){
n=rand()/100;
v1[i]=n;
v2[i]=v1[i]*5;
}
cout<<"Vec 1 (numeros no multiplicados)"<<endl;
for(int i=0; i<=19; i++){
cout<<v1[i]<<endl;
}
cout<<endl;
cout<<"Vec 2 (numeros multiplicados)"<<endl;
for(int i=0; i<=19; i++){
cout<<v2[i]<<endl;
}
system ("PAUSE");
return 0;
}
Pruebas del funcionamiento:
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int v1[20], v2[20], n;
int main(){
srand(time(NULL));
for(int i=0; i<=19; i++){
n=rand()/100;
v1[i]=n;
v2[i]=v1[i]*5;
}
cout<<"Vec 1 (numeros no multiplicados)"<<endl;
for(int i=0; i<=19; i++){
cout<<v1[i]<<endl;
}
cout<<endl;
cout<<"Vec 2 (numeros multiplicados)"<<endl;
for(int i=0; i<=19; i++){
cout<<v2[i]<<endl;
}
system ("PAUSE");
return 0;
}
Pruebas del funcionamiento:
Ejercicio 9:
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <time.h>
using namespace std;
int a,b,c,vec1[60],vec2[60],vec3[60];
int main(){
int num;
srand(time(NULL));
for(int i=0; i<=59; i++){
num=rand()/10;
if(num>=1 && num<=99){
vec1[a]=num;
a++;
}
if(num>=100 && num<=999){
vec2[b]=num;
b++;
}
if(num<=1000 && num>=9999){
vec3[c]=num;
c++;
}
}
cout<<"Decenas"<<endl;
for(int i=0; i<=a; i++){
cout<<vec1[i]<<endl;
}
cout<<endl;
cout<<"Centenas"<<endl;
for(int i=0; i<=b; i++){
cout<<vec2[i]<<endl;
}
cout<<endl;
cout<<"Millares"<<endl;
for(int i=0; i<=c; i++){
cout<<vec3[i]<<endl;
}
cout<<endl;
system("pause");
return 0;
}
Prueba del funcionamiento:
#include <stdlib.h>
#include <iostream>
#include <time.h>
using namespace std;
int a,b,c,vec1[60],vec2[60],vec3[60];
int main(){
int num;
srand(time(NULL));
for(int i=0; i<=59; i++){
num=rand()/10;
if(num>=1 && num<=99){
vec1[a]=num;
a++;
}
if(num>=100 && num<=999){
vec2[b]=num;
b++;
}
if(num<=1000 && num>=9999){
vec3[c]=num;
c++;
}
}
cout<<"Decenas"<<endl;
for(int i=0; i<=a; i++){
cout<<vec1[i]<<endl;
}
cout<<endl;
cout<<"Centenas"<<endl;
for(int i=0; i<=b; i++){
cout<<vec2[i]<<endl;
}
cout<<endl;
cout<<"Millares"<<endl;
for(int i=0; i<=c; i++){
cout<<vec3[i]<<endl;
}
cout<<endl;
system("pause");
return 0;
}
Prueba del funcionamiento:
Ejericio 8:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int calificaciones[20], aprobados[20], reprobados[20], j, ap, rp, h;
int main (){
for (j=0;j<=19;j++){
cin>>calificaciones[j];
}
for (h=0;j<=19;h++){
if (calificaciones[h]>=7){
aprobados[ap]=calificaciones[h];
ap++;
}
if (calificaciones[h]<7){
reprobados[rp]=calificaciones[h];
rp++;
}
}
for(j=0;j<=ap;j++){
cout<<aprobados[j]<<endl;
}
for (h=0;h<=rp;h++){
cout<<reprobados[h]<<endl;
}
system("PAUSE");
return 0;
}
Prueba del funcionamiento:Ejercicio 7.2:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int n, n1, n2, cont;
int main()
{
n1= 1;
n2= 1;
cout<<n1<<endl;
cout<<n2<<endl;
while(n<6765)
{
n=n1+n2;
cout<<n<<endl;
n1=n2;
n2=n;
cont=cont+1;
}
system("PAUSE");
return 0;
}
Pruebas del funcionamiento:
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int n, n1, n2, cont;
int main()
{
n1= 1;
n2= 1;
cout<<n1<<endl;
cout<<n2<<endl;
while(n<6765)
{
n=n1+n2;
cout<<n<<endl;
n1=n2;
n2=n;
cont=cont+1;
}
system("PAUSE");
return 0;
}
Pruebas del funcionamiento:
Ejercicio 7:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n,n1,n2,cont;
int main()
{
n1=1;
n2=1;
cout<<n1 <<endl;
cout<<n2 <<endl;
for(cont=0;cont<=17;cont=cont+1)
{
n=n1+n2;
cout<<n <<endl;
n1=n2;
n2=n;
}
system("PAUSE");
return 0;
}
Pruebas del funcionamiento:
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n,n1,n2,cont;
int main()
{
n1=1;
n2=1;
cout<<n1 <<endl;
cout<<n2 <<endl;
for(cont=0;cont<=17;cont=cont+1)
{
n=n1+n2;
cout<<n <<endl;
n1=n2;
n2=n;
}
system("PAUSE");
return 0;
}
Pruebas del funcionamiento:
Ejericio 6:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int j=105;
int main (){
do{
j=j-5;
cout<<j<<endl;
}while (j>5);
system ("PAUSE");
return 0;
}
Pruebas del funcionamiento:
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int j=105;
int main (){
do{
j=j-5;
cout<<j<<endl;
}while (j>5);
system ("PAUSE");
return 0;
}
Pruebas del funcionamiento:
Ejercicio 5:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
int aleatorio, j;
int main (){
srand(time(NULL));
for (j=1;j<=30;j++){
aleatorio=1+rand()%(1000);
if (aleatorio>20){
cout<<aleatorio<<endl;
}
}
system ("PAUSE");
return 0;
}
Pruebas del funcionamiento:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;
int aleatorio, j;
int main (){
srand(time(NULL));
for (j=1;j<=30;j++){
aleatorio=1+rand()%(1000);
if (aleatorio>20){
cout<<aleatorio<<endl;
}
}
system ("PAUSE");
return 0;
}
Pruebas del funcionamiento:
Ejercicio 4:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int n1, n2, n3, j, r;
int main (){
cout<<"numero 1"<<endl;
cin>>n1;
cout<<"numero 2"<<endl;
cin>>n2;
cout<<"numero 3"<<endl;
cin>>n3;
if (n2>n3){
for (j=n2;j>=n3;j--){
r=n1*j;
cout<<n1<<"x"<<j<<"="<<r<<endl;
}
}
if (n3>n2){
for(j=n2;j<=n3;j++){
r=n1*j;
cout<<n1<<"x"<<j<<"="<<r<<endl;
}
}
return 0;
}
Prueba del funcionamiento:
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int n1, n2, n3, j, r;
int main (){
cout<<"numero 1"<<endl;
cin>>n1;
cout<<"numero 2"<<endl;
cin>>n2;
cout<<"numero 3"<<endl;
cin>>n3;
if (n2>n3){
for (j=n2;j>=n3;j--){
r=n1*j;
cout<<n1<<"x"<<j<<"="<<r<<endl;
}
}
if (n3>n2){
for(j=n2;j<=n3;j++){
r=n1*j;
cout<<n1<<"x"<<j<<"="<<r<<endl;
}
}
return 0;
}
Prueba del funcionamiento:
Ejercicio 3:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int tabla, multiplo, j, r;
int main (){
cout<<"ingrese la tabla"<<endl;
cin>>tabla;
cout<<"ingrese el multiplo"<<endl;
cin>>multiplo;
for (j=1;j<=multiplo;j++){
r=tabla*j;
cout<<tabla<<"x"<<multiplo<<"="<<r<<endl;
}
return 0;
}
Prueba del funcionamiento:
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int tabla, multiplo, j, r;
int main (){
cout<<"ingrese la tabla"<<endl;
cin>>tabla;
cout<<"ingrese el multiplo"<<endl;
cin>>multiplo;
for (j=1;j<=multiplo;j++){
r=tabla*j;
cout<<tabla<<"x"<<multiplo<<"="<<r<<endl;
}
return 0;
}
Prueba del funcionamiento:
Ejercicio 2:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n1, j;
int main (){
cout<<"ingresa el numero"<<endl;
cin>>n1;
for (j=n1+1;j<=n1+10;j++){
cout<<j*j<<endl;
}
Pruebas del funcionamiento:
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n1, j;
int main (){
cout<<"ingresa el numero"<<endl;
cin>>n1;
for (j=n1+1;j<=n1+10;j++){
cout<<j*j<<endl;
}
Pruebas del funcionamiento:
Ejercicio 1:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n1, n2, j, n;
int main (){
cout<<"digite el primer numero"<<endl;
cin>>n1;
cout<<"digite el numero dos"<<endl;
cin>>n2;
for (j=n1+1;j<=n2-1;j++){
cout<<j<<endl;
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int n1, n2, j, n;
int main (){
cout<<"digite el primer numero"<<endl;
cin>>n1;
cout<<"digite el numero dos"<<endl;
cin>>n2;
for (j=n1+1;j<=n2-1;j++){
cout<<j<<endl;
}
return 0;
}
Suscribirse a:
Entradas (Atom)

















