Numero mayor a menor con ciclo repetitivo
Publicado por Brayan (3 intervenciones) el 06/10/2019 21:04:41
Hola quiero hacer un programa que al introducir 6 números los ordene de mayor a menor ya lo hice pero sin ciclos repetitivos y quiero saber como se puede hacer con ciclos. Les dejo el ejemplo que hice
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
program acendente;
uses crt;
var
a,b,c,d,e,f,g:integer;
begin
clrscr;
writeln('Escriba 6 numeros: ');
readln(a,b,c,d,e,f);
writeln;
if a>b then
begin
g:=a;
a:=b;
b:=g;
end;
if a>c then
begin
g:=a;
a:=c;
c:=g;
end;
if a>d then
begin
g:=a;
a:=d;
d:=g;
end;
if a>e then
begin
g:=a;
a:=e;
e:=g;
end;
if a>f then
begin
g:=a;
a:=f;
f:=g;
end;
if b>c then
begin
g:=b;
b:=c;
c:=g;
end;
if b>d then
begin
g:=b;
b:=d;
d:=g;
end;
if b>e then
begin
g:=b;
b:=e;
e:=g;
end;
if b>f then
begin
g:=b;
b:=f;
f:=g;
end;
if c>d then
begin
g:=c;
c:=d;
d:=g;
end;
if c>e then
begin
g:=c;
c:=e;
e:=g;
end;
if c>f then
begin
g:=c;
c:=f;
f:=g;
end;
if d>e then
begin
g:=d;
d:=e;
e:=g;
end;
if d>f then
begin
g:=d;
d:=f;
f:=g;
end;
if e>f then
begin
g:=e;
e:=f;
f:=g;
end;
if (a=b) or (a=c) or (a=d) or (a=e) or (a=f) then
writeln('Hay 2 o mas numeros iguales')
else
if (b=a) or (b=c) or (b=d) or (b=e) or (b=f) then
writeln('Hay 2 o mas numeros iguales')
else
if (c=b) or (c=a) or (c=d) or (c=e) or (c=f) then
writeln('Hay 2 o mas numeros iguales')
else
if (d=b) or (d=c) or (d=a) or (d=e) or (d=f) then
writeln('Hay 2 o mas numeros iguales')
else
if (e=b) or (e=c) or (e=d) or (e=a) or (e=f) then
writeln('Hay 2 o mas numeros iguales')
else
if (f=b) or (f=c) or (f=d) or (f=e) or (f=a) then
writeln('Hay 2 o mas numeros iguales')
else
begin
writeln('Los numeros de mayor a menor son: ');
writeln(f,' ',e,' ',d,' ',c,' ',b,' ',a);
writeln;
writeln('Los numeros de menor a mayor son: ');
writeln(a,' ',b,' ',c,' ',d,' ',e,' ',f);
end;
readkey;
end.
Valora esta pregunta


0