You are on page 1of 3

PAREDES PILLCO ALVARO SIMON

30. Programa desplegar en pantalla lo sgte, para cualquier n>0:



N=5
11111
22222
33333
44444
55555
N=5
12345
1234
123
12
1
N=5
12345
1234
123
12
1
N=5
5
4
3
2
1
N=5
1
2
3
4
5
N=5
12345
54321
1234
4321
123
321
12
21
1
1
#include<iostream>
#include<stdlib.h>
using namespace std;
void primera()
{
int n;
do{cout<<"Ingrese n"<<endl;
cin>>n;}while(n<=0);
for(int a=1;a<=n;a++)
{
for(int b=1;b<=n;b++)
{
cout<<a;
}cout<<endl;
}
}
void segunda()
{
int n,c;
do{cout<<"Ingrese n"<<endl;
cin>>n;}while(n<=0);c=n;
for(int a=1;a<=n;a++)
{
for(int b=1;b<=c;b++)
{
cout<<b;
}cout<<endl;c--;
}
}
PAREDES PILLCO ALVARO SIMON
void tercera()
{
int n,c;
do{cout<<"Ingrese n"<<endl;
cin>>n;}while(n<=0);c=n;
for(int a=1;a<=n;a++)
{
for(int b=1;b<=c;b++)
{
cout<<b;
}cout<<endl;c--;
}
}
void cuarta()
{
int n,c;
do{cout<<"Ingrese n"<<endl;
cin>>n;}while(n<=0);c=n;
for(int a=1;a<=n;a++)
{
for(int x=1;x<c;x++){cout<<" ";}
cout<<c<<endl;c--;
}
}
void quinta()
{
int n,c;
do{cout<<"Ingrese n"<<endl;
cin>>n;}while(n<=0);c=n;
for(int a=1;a<=n;a++)
{
for(int x=1;x<a;x++){cout<<" ";}
cout<<a<<endl;
}
}
void sexta()
{
int n,c;
do{cout<<"Ingrese n"<<endl;
cin>>n;}while(n<=0);
for(int a=n;a>=1;a--)
{ c=a;
for(int x=1;x<=a;x++){cout<<x;}cout<<endl;
for(c;c>=1;c--){cout<<c;}cout<<endl;
}
PAREDES PILLCO ALVARO SIMON
}
main()
{ int n;
do{cout<<"Este programa realiza 6 funciones para numeros."<<endl
<<"Ingrese 0 para salir."<<endl
<<"1. Primera figura."<<endl
<<"2. Segunda figura."<<endl
<<"3. Tercera figura."<<endl
<<"4. Cuarta figura."<<endl
<<"5. Quinta figura."<<endl
<<"6. Sexta figura."<<endl;
cin>>n;
switch(n)
{
case 1:primera();system("PAUSE");system("CLS");break;
case 2:segunda();system("PAUSE");system("CLS");break;
case 3:tercera();system("PAUSE");system("CLS");break;
case 4:cuarta();system("PAUSE");system("CLS");break;
case 5:quinta();system("PAUSE");system("CLS");break;
case 6:sexta();system("PAUSE");system("CLS");break;
case 0:system("PAUSE");system("CLS");break;
default:cout<<"Ingrese un numero
valido"<<endl;system("PAUSE");system("CLS");break;
}
}while(n!=0);
}

You might also like