forked from MaterialesProgramacion/ProblemasProgramacion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rectanguloAsteriscos.c
62 lines (56 loc) · 971 Bytes
/
rectanguloAsteriscos.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* @authors Equipo docente programacion grado de ingenieria
* @university UAL
* @date 2019-02-06
* */
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#include <math.h>
int main(){
char c;
int a;
int h;
int i,j;
do{ system("cls");
printf("RECTANGULO DE ASTERISCOS\n");
printf("========================\n\n");
do{
printf("Introduzca ancho [3-40]: ");
scanf(" %d",&a);
}while((a<3)||(a>40));
do{
printf("Introduzca altura [3-20]: ");
scanf(" %d",&h);
}while((h<3)||(h>40));
/* Arista superior */
j=1;
while(j<=a){
printf(" *");
++j;
}
printf("\n");
/* Aristas laterales */
i=2;
while(i<h){
printf(" *");
j=2;
while(j<a){
printf(" ");
++j;
}
printf(" *\n");
++i;
}
/* Arista inferior */
j=1;
while(j<=a){
printf(" *");
++j;
}
printf("\n\nDesea efectuar una nueva operacion (s/n)? ");
c=toupper(getch());
}while (c!='N');
return 0;
}