-
vars,i:longint;
beginfor i:=11 to 2009 do begins:=s+i;
end;writeln(s);
end.Pretty simple, boss, give salary!!
-
const num = 5;
var n: integer;
function r(n : integer) :integer;
var i : integer;
beginif n <= num then
beginr := n;
exit;end;
for i :=1 to num do
if r(n-i) <0 then
beginr:=i;
exit;end;
r:=-1;
end;begin
readln(n);
writeln(r(n));
end.The general process is to read the data n (which requires your input) and then output r(n), and because r(n) is a function, the r function is executed. If n is less than or equal to 5, then r=n, and then the function is terminated and the function value is output; If n is greater than 5, jump to the for loop.
You should also understand the following...
Hee-hee-hee-hee-???hee-,,,hee
-
Just buy a book and read it.
num is a constant, always equal to 10;
function is a function;
for··· to··· do is a loop;
if is to judge;
readln is a write;
writeln is the output;
begin begin;
end.
-
var i,j,n,k,l,m:longint;s1:string;s:array[0..10]of string;ch:char;
a:array[0..10]of longint;
beginreadln(n);
readln(s1);
l:=length(s1);m:=1;
for i:= 1 to n do
beginj:=1;
while (s1[j]>',')and(m<>l+1) dobegin
s[i,j]:=s1[m];
inc(j);inc(m);
end;a[i]:=j-1;
inc(m);
end;for i:= 1 to n-1 do
for j:= i+1 to n do
beginif s[i,1]for k:=1 to 200do
begins[0,k]:=s[i,k];s[i,k]:=s[j,k];s[j,k]:=s[0,k];
end;a[0]:=a[i];a[i]:=a[j];a[j]:=a[0];
end;end;
for i:= 1 to n do
beginfor j:= 1 to a[i] do
beginwrite(s[i,j]);
end;end;
end.It's a greedy idea: read it as a string, sort it by the first word, and output it at the end.
The three parts are: 1: input into an array of strings;
2: Sort according to the order of the size of the first character;
3: Output in the order in which it is arranged;
Note: Array A records the length of each number. It needs to be adjusted along with the string.
-
This is the C language.
There are subroutines. Don't know what the subroutine is.
Can't translate. #include
#include
#include
#include
-
var a:integer;
c:real;
beginfor a:=1 to 10 do
c:=c+a/10;
write(c);
end.The one above, annoying.
How could it be wrong.
Add one to yourself, it's definitely right.
-
vara,b:longint;
beginfor a:=1 to 9 do begina:=a*;
b:=b+a;
end;writeln(b);
end.The owner of the small silk watchtower adopts !! Sprout!!
-
vara, b: integer;
function work(a, b: integer): integer;Find the greatest common divisor of a and b.
beginif a mod b <>0 then if a is not divisible by b.
work := work(b, a mod b) The greatest common divisor of A and B is equal to the greatest common divisor of B and A mod B.
elsework := b;If a is divisible by b, the greatest common divisor of a and b is equal to b
end;begin
read(a, b);Read in the values of a and b.
writeln(work(a, b));work is a custom function name (self-chosen), and its functions have been described in detail above.
end.Input: 20 12
Output: 4
-
This program is to find the greatest common divisor, how to translate this word by word???
var (defines variables).
a, b: integer;(The a,b variables belong to integer integers).
functionwork(a, b: integer): integer;(Custom function work to find the greatest common divisor).
beginif a mod b <>0 then (if a is divided by b without zero).
work := work(b, a mod b) (use b, a mod b as a variable to find the common divisor of the two of them).
else
work := b;(The greatest common divisor is b).
end;begin
read(a, b);(read a, b).
writeln(work(a, b));output (the greatest common divisor obtained after the function is called a,b)).
end.
-
program ft;
uses crt;
vardp:array[0..24][0..3500] of integer;
v,a:array[0..25] of integer;
i,j,k,n,sum:integer;
beginread(sum,n);
for i:=1 to n do read(v[i]);
for i:=1 to n do
for j:=1 to sum do begindp[i][j]:=dp[i-1][j];
if v[i]<=j then
if dp[i-1][j]>(dp[i-1][j-v[i]]+v[i]) then
dp[i][j]:=dp[i-1][j];
else then
dp[i][j]:=dp[i-1][j-v[i]]+v[i];
end;write(dp[n][sum]);
readkey();
end.Second, please ask a separate question.
-
program e2;
varx,x1,y1,y,t,i,j,s,h,h1:integer;
a:array[0..10]of integer;
b:array[0..10]of integer;
c:array[0..10]of integer;
beginh1:=1;
writeln('Please enter two numbers:');
writeln('x= ');
readln(x);
writeln('y= ');
readln(y);
x1:=x; y1:=y;
for i:=0 to 7 do
begina[i]:=x mod 2;
b[i]:=y mod 2;
x:=x div 2;
y:=y div 2;
end;for i:=0 to 7 do
beginc[i]:=a[i]+b[i]+c[i];
if (c[i]=2) then
beginc[i]:=0;
c[i+1]:=c[i+1]+1;
end;end;
for t:=0 to 7 do
beginh:=0;h1:=1;
while (hbegin
h1:=h1*2;
h:=h+1;
end;s:=s+c[t]*h1;
end;writeln(x1,'+',y1,'=',s);
for i:=7 downto 0 do
write(a[i]);
write('+');
for i:=7 downto 0 do
write(b[i]);
write('=');
for i:=7 downto 0 do
writeln(c[i]);
end.Maybe some formats are not as good as you want, but pascal's output statements are write and writeln, the first is that there is no line break after output, and the second is line break after output, you see what you have to change No, I tried the compilation and passed.
-
Source code .........
#include""
Did you quote your own library?
The big country rides 5 with a gorgeous melody and a loving shoulder ride. She is very suitable, moisturizing and weighs 125 pounds (57 kg). Today, she wants to have some nice long shoulders in the country to navigate. >>>More
The first one. Victor usually wakes up at 7 in the morning. Have a 20-minute morning exercise, take a shower, eat a good breakfast, and then go to work at 8 a.m. He usually goes by car, arriving at 8:30. >>>More
Hello to the landlords! I want to renew my contract.
How about we renew the contract for another 1 and a half years without going through an intermediary this time? >>>More
hello everyone. my name is xx and i'm twelve years old now. i like swimming and playing basketball. >>>More
It's been a hard journey
July 10, 2006 July 10, 2006 On a sunny day >>>More