记住给出数字
0
--
9
各出现了几次
输出时先输出一个出现过的最小非零数字,
再把剩下的数字由小到大输出。
程序:
Program
ex
Var
a:
array['0'..'9']
of
byte
ch:
char
Begin
fillchar(a,
10,
0)
while
not
eoln
do
begin
read(ch)
a[ch]
:=
a[ch]
+
1
end
for
ch:='1'
to
'9'
do
if
a[ch]
>
0
then
begin
write(ch)
a[ch]
:=
a[ch]
-
1
break
end
for
ch:='0'
to
'9'
do
while
a[ch]
>
0
do
begin
write(ch)
a[ch]
:=
a[ch]
-
1
end
writeln
End.
为了保留格式用了全角空格。
var i,j,n,m,len_a:integera:array[1..1000] of integer
begin
readln(m)
write(m,'=')//要打1就改成write(m,'=','1*')
n:=m
for i:=2 to m div 2 do
begin
while n mod i=0 do
begin
n:=n div i
inc(len_a)
a[len_a]:=i
end
end
for i:=1 to len_a-1 do
write(a[i],'*')
writeln(a[len_a])
end.
第一题- -;program dsq
function check(x:longint):boolean
var i:longint
f:boolean
begin
f:=false
for i:=2 to sqrt(x) do if x mod i=0 then
begin
f:=true
break
end
if not f then exit(true)
end
procedure print(xlongint)
begin
writeln(n,'=',x,'+',n-x)
end
var n,i:longint
begin
readln(n)
for i:=2 to n-2 do
begin
if check(i) then
if check(n-i) then
begin
print(i)
break
end
end
end.
第二题- -;
program dsq
var n,i:longint
begin
readln(n)
write(n,'=1')
i:=2
while i<=n do
begin
while n mod i =0 do
begin
write('*',i)
n:=n div i
end
inc(i)
end
end.
第3题- -;
program dsq
var s:string
i:longint
n,k:longint
begin
readln(s)
k:=1n:=0
for i:=length(s) downto 1 do
begin
n:=n+k*(ord(s[i])-48)
k:=k*2
end
writeln(n)
end
第4题- -;
program dsq
var i,n:longint
f:boolean
begin
readln(n)
f:=false
for i:=2 to sqrt(n) do if n mod i=0 then
begin
f:=true
break
end
if not f then writeln('sushu')else writeln('Not sushu')
end.
第5题- -;
program dsq
var l,i:longint
s:string
f:boolean
begin
readln(l)
str(l,s)
f:=false
for i:=1 to length(s) div 2 do
if s[i]<>s[length(s)-i+1] then
begin
f:=true
break
end
if not f then writeln('huiwenshu') else writeln('Not huiwenshu')
end.
全是笔记本上写的,可能有点小错误,但是基本不会错-。-;
有任何关于pascal的问题都可以来问我,没有我不会的-。-;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)