130 likes | 431 Views
十八届第二题. var n,i,ans:integer; function gcd (a,b :integer) : integer; begin if a mod b=0 then gcd := b else gcd := gcd (b,a mod b); end; begin readln(n); ans := 0; for i:=1 to n do if gcd(n,i)=i then ans := ans + 1; writeln(ans); end. 输入:120 输出:_____________.
E N D
十八届第二题 var n,i,ans:integer; function gcd(a,b :integer) : integer; begin if a mod b=0 then gcd :=b else gcd := gcd(b,a mod b); end; begin readln(n); ans := 0; for i:=1 to n do if gcd(n,i)=ithen ans := ans + 1; writeln(ans); end. 输入:120 输出:_____________
var n,i,ans:integer; function gcd(a,b :integer) : integer; begin if a mod b=0 then gcd :=b else gcd := gcd(b,a mod b); end; begin readln(n); ans := 0; for i:=1 to n do if gcd(n,i)=ithen ans := ans + 1; writeln(ans); end. 输入:120 输出:_____________ 120=1*2*6*10 120=1*2*2*3*2*5 8 1 2 3 4 5 6 12 24 10 15 20 30 40 60 120
十四届第二题 2.procedure foo(a,b,c:integer); begin if a>b then foo(c,a,b) else writeln(a,',',b,',',c) end; var a,b,c:integer; begin readln(a,b,c); foo(a,b,c); end. 输入:2 1 3 输出:_________________
十四届第二题 2.procedure foo(a,b,c:integer); begin if a>b then foo(c,a,b) else writeln(a,',',b,',',c) end; var a,b,c:integer; begin readln(a,b,c); foo(a,b,c); end. 输入:2 1 3 输出:_________________ 2 1 3 3 2 1 1 3 2
十四届第三题 procedure f(a,b,c:integer); begin write(a,b,c,'/'); If (a=3)and(b=2)and(c=1) then exit; if (b<c) then f(a,c,b) else if a<b then if a<c then f(c,a,b) else f(b,c,a); end; var a,b,c:integer; begin readln(a,b,c); f(a,b,c); end. 输入:1 3 2
十四届第三题 y procedure f(a,b,c:integer); begin write(a,b,c,'/'); If (a=3)and(b=2)and(c=1) then exit; if (b<c) then f(a,c,b) else if a<b then if a<c then f(c,a,b) else f(b,c,a); end; var a,b,c:integer; begin readln(a,b,c); f(a,b,c); end. 输入:1 3 2 b<c n f(a,c,b) y a<b y a<c n f(c,a,b) f(b,c,a)
十五届第一题 var a,b:integer; function work(a,b:integer):integer; begin if a mod b <> 0 then work := work(b,a mod b) else work := b; end; begin read(a,b); writeln(work(a,b)); end. 输入:123 321
十五届第一题 var a,b:integer; function work(a,b:integer):integer; begin if a mod b <> 0 then work := work(b,a mod b) else work := b; end; begin read(a,b); writeln(work(a,b)); end. 输入:123 321 3
ACSII码(美国标准信息交换码) AmericanStandardCode forInformationInterchange
program ex1188; var st1,st2:string; a,b:array[1..250] of integer; len1,len2,len,c,i:integer; begin readln(st1); len1:=length(st1); readln(st2); len2:=length(st2); for i:=1 to len1 do a[i]:=ord(st1[len1-i+1])-48; for i:=1 to len2 do b[i]:=ord(st2[len2-i+1])-48; if len1>len2 then len:=len1 else len:=len2; c:=0; for i:=1 to len do begin a[i]:=a[i]+b[i]+c; c:=a[i] div 10; a[i]:=a[i] mod 10; end; if c<>0 then write(c); for i:=len downto 1 do write(a[i]); end.
var s:string; i,j,len,k:integer; begin readln(s); len:=length(s); for i:=1 to len do if (ord(s[i])>=ord('A')) and (ord(s[i])<=ord('Z')) then s[i]::=chr(ord(s[i])-ord('A')+ord('a')); for i:=1 to len do if (ord(s[i])<ord('x')) then s:=chr(ord(s[i])+3) else s[i]:=chr(ord(s[i])-23); write(s); write('/'); for j:=1 to 3 do begin i:=1; while i<=len-j do begin s[i]:=s[i+j]; i:=i+j; end; end; writeln(s); end. 十五届第四题 输入:ABCDEFGuvwxyz 输出:________________________________
abcdefghijklmnopqrstuvwxyz var s:string; i,j,len,k:integer; begin readln(s); len:=length(s); for i:=1 to len do if (ord(s[i])>=ord('A')) and (ord(s[i])<=ord('Z')) then s[i]:=chr(ord(s[i])-ord('A')+ord('a')); for i:=1 to len do if (ord(s[i])<ord('x')) then s[i]:=chr(ord(s[i])+3) else s[i]:=chr(ord(s[i])-23); for i:=1 to len do write(s[i]); write('/'); for j:=1 to 3 do begin i:=1; while i<=len-j do begin s[i]:=s[i+j]; i:=i+j; end; end; for i:=1 to lenwriteln(s[i]); end. 输入:ABCDEFGuvwxyz 13 abcdefguvwxyz defghijxyzabc defghijxyzabc