1) на Pascal: var t,i,j:integer; a:array[1..4]of integer; begin for i:=1 to 4 do begin write('Vvedite ',i,'-i 4islo: '); readln(a); end; for i:=2 to 4 do for j:=4 downto i do if a[j-1]>a[j] then begin t:=a[j-1]; a[j-1]:=a[j]; a[j]:=t; end; writeln('Raspolagaem 4isla v poryadke vozrastaniya:'); for i:=1 to 4 do writeln(a); readln; end.
2) на С: #include <stdio.h> #include <conio.h> void main(void){ int n,a,b,c,d; printf("\nVvedite 4x-znachnoe chislo n: "); scanf("%i", &n); a=n/1000; b=(n-a*1000)/100; c=(n-a*1000-b*100)/10; d=n-a*1000-b*100-c*10; if (a+b==c+d) printf("true"); else printf("false"); getch(); };
1) на Pascal:
var
t,i,j:integer;
a:array[1..4]of integer;
begin
for i:=1 to 4 do
begin
write('Vvedite ',i,'-i 4islo: ');
readln(a);
end;
for i:=2 to 4 do
for j:=4 downto i do
if a[j-1]>a[j] then
begin
t:=a[j-1];
a[j-1]:=a[j];
a[j]:=t;
end;
writeln('Raspolagaem 4isla v poryadke vozrastaniya:');
for i:=1 to 4 do
writeln(a);
readln;
end.
2) на С:
#include <stdio.h>
#include <conio.h>
void main(void){
int n,a,b,c,d;
printf("\nVvedite 4x-znachnoe chislo n: ");
scanf("%i", &n);
a=n/1000;
b=(n-a*1000)/100;
c=(n-a*1000-b*100)/10;
d=n-a*1000-b*100-c*10;
if (a+b==c+d) printf("true");
else printf("false");
getch();
};