Dev - C++ - AYUDA,cuando pido la opción b o c no se realizan; se hizo con repeticion el recursivo no jala

 
Vista:

AYUDA,cuando pido la opción b o c no se realizan; se hizo con repeticion el recursivo no jala

Publicado por macedelhumeau (1 intervención) el 25/11/2020 07:06:59
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include<stdio.h>
#include<string.h>
 
main(){
	int recu;
	recu=1;
	do{
		char op,nm[0],numenor[0],numayor[0];
		int reg, i, m,mayor,menor;
		int region=0,a=0;
		int tcf,tca,tna,tnf,tgf,tga,tcra,tcaf,tpf,tpa,tsf,tsa;
		float t=0, prom=0,pts,ptc,ptp;
 
		printf("\n\n[a]El promedio anual de cada region.");
		printf("\n[b]El mes y registro con la mayor y menor temperaturas,y a que zona de pertenencia.");
		printf("\n[c]Región con el mayor promedio de temperatura anual.");
		printf("\nIngresa la opcion deseada :");
		scanf(" %c",&op);
		switch(op)
		{
			case 'a': /*El promedio anual de cada región. FOR*/
				printf("Cual region quieres calcular? :\n ");
				printf("[1]NORTE\n");
				printf("[2]SUR\n");
				printf("[3]PACiFICO\n");
				printf("[4]CARIBE\n");
				printf("[5]GOLFO\n");
				printf("[6]CENTRO\n");
				scanf("%d",&reg);
				switch(reg)
				{
					case 1 :
					tnf = 0;
					 for(i=1; i<=12; i++){
					 printf("Ingrese las temperaturas mensuales del Norte: \n");
					 scanf("%d", &tna);
					 tnf=tnf+tna;
					}
					prom=tnf/12;
					printf("El promedio de las temperaturas es: %f", prom);
					break;
 
					case 2 :
						tnf = 0;
					 for(i=1; i<=12; i++){
					 printf("Ingrese las temperaturas mensuales del Sur: \n");
					 scanf("%d", &tsa);
					 tsf=tsf+tsa;
					}
					prom=tsf/12;
					printf("El promedio de las temperaturas es: %f", prom);
					break;
 
					case 3 :
						tnf = 0;
					 for(i=1; i<=12; i++){
					 printf("Ingrese las temperaturas mensuales del Pacifico: \n");
					 scanf("%d", &tpa);
					 tpf=tpf+tpa;
					}
					prom=tpf/12;
					printf("El promedio de las temperaturas es: %f", prom);
					break;
 
					case 4 :
						tnf = 0;
					 for(i=1; i<=12; i++){
					 printf("Ingrese las temperaturas mensuales del Caribe: \n");
					 scanf("%d", &tcra);
					 tcaf=tcaf+tcra;
					}
					prom=tcaf/12;
					printf("El promedio de las temperaturas es: %f", prom);
					break;
 
					case 5 :
						tnf = 0;
					 for(i=1; i<=12; i++){
					 printf("Ingrese las temperaturas mensuales del Golfo: \n");
					 scanf("%d", &tga);
					 tgf=tgf+tga;
					}
					prom=tgf/12;
					printf("El promedio de las temperaturas es: %f", prom);
					break;
 
					case 6 :
						tnf = 0;
					 for(i=1; i<=12; i++){
					 printf("Ingrese las temperaturas mensuales del Centro: \n");
					 scanf("%d", &tca);
					 tcf=tcf+tca;
					}
					prom=tcf/12;
					printf("El promedio de las temperaturas es: %f", prom);
					break;
 
			case 'b': /*El mes y registro con la mayor y menor temperaturas, y que además indique a qué zona pertenecen estos registros. WHILE*/
 
				reg=1;
				while(reg<=6)
				{
					printf("\n Region %d", reg);
					m=1;
					while(m<=12)
					{
						printf("\nMes de registro de la temperatura");
						scanf("%s",&nm);
						printf("Ingresa la temperatura");
						scanf("%f",&t);
 
						if(t>mayor)
						{
							mayor=t;
							strcpy(numayor,nm);
						}
						if(t<menor)
						{
							menor=t;
							strcpy(numenor,nm);
						}
						m=m+1;
					}
					if (reg==1)
					printf("REGION NORTE: La temperatura menor fue %s en el mes %s y la mayor fue %s",numenor,numayor,nm);
					if (reg==2)
					printf("REGION SUR: La temperatura menor fue %s en el mes %s y la mayor fue %s",numenor,numayor,nm);
					if (reg==3)
					printf("REGION PACIFICO: La temperatura menor fue %s en el mes %s y la mayor fue %s",numenor,numayor,nm);
					if (reg==4)
					printf("REGION CARIBE: La temperatura menor fue %s en el mes %s y la mayor fue %s",numenor,numayor,nm);
					if (reg==5)
					printf("REGION GOLFO: La temperatura menor fue %s en el mes %s y la mayor fue %s",numenor,numayor,nm);
					if (reg==6)
					printf("REGION CENTRO: La temperatura menor fue %s en el mes %s y la mayor fue %s",numenor,numayor,nm);
				}
				break;
 
 
 
			case 'c': /*Determine cuál de las regiones SUR, PACÍFICO y CARIBE tienen el mayor promedio de temperatura anual. DO WHILE*/
			do{
				printf("Ingrese el promedio de temperatura anual de la region Sur");
				scanf("%f",&pts);
				printf("Ingrese el promedio de temperatura anual de la region Pacifico");
				scanf("%f",&ptp);
				printf("Ingrese el promedio de temperatura anual de la region Caribe");
				scanf("%f",&ptc);
 
				if(pts>ptp && pts>ptc)
				printf("\n\nLa región con el mayor promedio de temperatura es %f: ",pts);
 
				if(ptp>pts && ptp>ptc)
				printf("\n\nLa región con el mayor promedio de temperatura es %f: ",ptp);
 
				else
				printf("\n\nLa región con el mayor promedio de temperatura es %f: ",ptc);
 
				break;
			}
			while(t<1000);
			break;
		}
 
		printf("\n[1] Otra opcion del menu");
		printf("\n[0] Salir del programa");
		scanf("%d",&recu);
 
	}
	}
	while(recu=1);
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder