-
Just use an array.
var a:array[1..1000]of longint;
b:array[1..1000]of longint;
i,x,n:longint;
beginread(n);
for i:=1 to n do read(a[i]);
for i:=n downto 1 do b[i]:=a[n-i+1];
for i:=1 to n do write(b[i],' ');
end.This method is a little bit more violent, and you can also swap directly on an array.
var a:array[1..1000]of longint;
i,x,n,j:longint;
beginread(n);
for i:=1 to n do read(a[i]);
for i:=1 to (n div 2)dobeginx:=a[n-i+1];
a[n-i+1]:=a[i];
a[i]:=x;
end;for i:=1 to n do write(a[i],' ');
end.This method will work a little faster.
Pure hand begging.
-
The crux of the matter is to deal with the 0 at the end, and the procedure is as follows:
Enter a positive integer and output it in reverse order, with a space after each digit stop.
Enter a positive integer n, and you can assume that n is in the int range.
The output outputs n in reverse order, with a space after each number, and the output occupies a row. /#include
int main()
int i;
int n;
scanf("%d",&n);
int num = 0;
for(i = 0; ;i ++
num = n % 10;
n /=10;
printf("%d",num);
if( n < 1)
break;
return 0;
-
The crux of the matter is to deal with the 0 at the end, and the procedure is as follows:
Enter a positive integer and output it in reverse order, with a space after each number.
Input a positive integer n, and you can assume that n is output in the int range and output n in reverse order, with a space after each number, and the output takes up a row. /#include
int main()
int i;
int n;
scanf("%d",&n);
int num = 0;
for(i = 0; ;i ++
num = n % 10;
n /= 10;
printf("%d",num);
if( n < 1)
break;
return 0;
-
It's super easy to handle it as a string
vari,j:longint;
n:string;
beginreadln(n);
for i:=length(n) downto 1 doif n[i]<>'0' then break;This step is to remove the precedent 0
for j:=i downto 1 do write(n[j]);
writeln;
end.Of course, you can use arrays as well.
Define n as an array of characters n:array [1..9] of char;
Do this by also noting the length.
Of course, it is possible to do it directly with plastic surgery!
varn:longint;
beginreadln(n);
while (n mod 10=0) do n:=n div 10;This step is to remove the precedent 0
while n<>0 do
beginwrite(n mod 10);output last digit n:=n div 10; Delete the last digit end;
writeln;
end.Choose from three methods
-
The crux of the matter is to deal with the 0
The procedure is as follows: var s:string;
i,j:integer;
beginreadln(s);Integers are stored as strings;
for i:=length(s) downto 1 doif s[i]<>'0' then break;This step is to find the position of the non-0 number on the far right of the S string and write it down with i;
for j:=i downto 1 do write(s[j]);
readln;
end.
varn,i,j:integer;
beginreadln(n); >>>More
The specific process is as Richardbao2000 said: 1, read 10 numbers. >>>More
The N85 is a very bad machine. First of all, the workmanship of the machine is very good, the lines are sleek, the shape is stylish, and it is slim. The process of the slide cover is also very good, it is not tight or loose, and it feels very good, but the slide is relatively tight. >>>More
As we all know, Nero is an excellent disc burning software, and it has always been praised for its power and stability. >>>More
Hello landlord: Since you use ninety-seven, it is a full keyboard, it is recommended to use A4, but I don't object to you using Sogou, I use eight five, I feel that A4 is not suitable, so I also use Sogou. >>>More