1樓:天外贏龍
program tm1;
var a,b:array[1..1000] of integer;
i,j,k,m:integer;
begin
k:=1;
for i:=2 to 1000 do
begin
for j:=2 to i-1 do
begin
if i mod j=0 then begin
a[i]:=a[i]+j;
b[k]:=j;
k:=k+1;
end;
end;
if (a[i]+1)=i then begin
write(i);
write(':=1');
for m:=1 to k-1 do write('+',b[m]);
writeln
end;
k:=1;
end;
readln
end.
方格program exampleb;
const link:array[1..6,1..2] of integer=
((1,2),(1,4),(2,5),(4,7),(5,8),(7,8));
var b:array[1..8] of integer;
procedure print;
begin
writeln(' ',b[1]:2);
writeln(b[2]:2,b[3]:2,b[4]:2);
writeln(b[5]:2,b[6]:2,b[7]:2);
writeln(' ',b[8]:2)
end;
function choose:boolean;
var i: integer;
begin
choose:= false;
for i:=1 to 6 do
if abs(b[link[i, 1]] - b[link[i ,2]]) = 1 then exit;
choose := true
end;
procedure try;
begin
for b[2]:=3 to 6 do
for b[4]:= 3 to 6 do
if b[2]<>b[4] then
for b[5]:= 3 to 6 do
if (b[5]<>b[2]) and (b[5]<>b[4]) then
begin
b[7]:= 18 - b[2] - b[4] - b[5];
if choose then print;
end; end;
begin
b[1]:=2;b[3]:=8;b[6]:= 1;b[8]:=7;
try;
b[1]:=7;b[3]:=1 ;b[6]:=8;b[8]:=2;
try; readln
end.
2樓:匿名使用者
var i,j,m:integer;
begin
for j:=2 to 2000 do beginm:=0;
for i:=1 to j-1 do
if j mod i=0 then m:=m+1;
if m=j then begin
write(m,'=','1');
for i:=2 to j do if j mod i=0 then write('+',i);
writeln;
end;end;
readln
end.
c語言程式設計問題
3樓:手機使用者
解題思bai路:完全跟百錢買百雞的問題是du一樣的!設大zhi馬,中馬,小馬dao的匹数分別為x,y,z;可以得到回兩個方程:
x+y+z=100; 3*x+2*y+z/2=100; 將第二個
答方程變形為:6*x+4*y+z=200; 從第二個方程變形的方程中,我們可以看到,x的最大值為200/6=33.3;即中馬,小馬都不用,只用大馬最多用34;1<=x<=34; 同樣中馬y的最大值為200/4=50;1<=y<=50;再將第三個方程減去第一方程變成5*x+3*y=100;這個方程就是我們簡化後的判斷條件用列舉法求可的如下的程式:
#include
int main()}
pascal程式設計問題
4樓:匿名使用者
因為機器上沒有安裝pascal,所以用delphi的控制台來實現。62616964757a686964616fe78988e69d8331333330346531
5樓:
var i, j : longint;
r, s, t : string;
temp : char;
begin
readln(r);
readln(s);
t := s;
for i := 1 to length(r) do
begin
if r[i] = 'a' then
begin
for j := 1 to length(s) div 2 do
begin
temp := s[j];
s[j] := s[length(s) - j + 1];
s[length(s) - j + 1] := temp;
end;
end;
if r[i] = 'c' then
begin
for j := length(s) downto 1 do
s[j+1] := s[j];
s[1] := t[length(t)];
end;
if r[i] = 'e' then
begin
for j := 1 to length(s) div 2 do
s[j] := t[j + (length(t) + 1) div 2];
for j := length(s) div 2 + 1 to length(s) do
s[j] := t[j - (length(t) + 1) div 2];
if length(s) mod 2 = 1 then
s[length(s) div 2 + 1] := t[length(t) div 2 + 1];
end;
if r[i] = 'j' then
begin
for j := 1 to length(s) do
s[j] := s[j+1];
s[length(s)] := t[1];
end;
if r[i] = 'm' then
begin
for j := 1 to length(s) do
if ord(s[j]) in [49..57] then
s[j] := chr(ord(s[j]) - 1)
else
if ord(s[j]) = 48 then
s[j] := chr(57);
end;
if r[i] = 'p' then
begin
for j := 1 to length(s) do
if ord(s[j]) in [48..56] then
s[j] := chr(ord(s[j]) + 1)
else
if ord(s[j]) = 57 then
s[j] := chr(48);
end;
end;
writeln(s);
end.
6樓:匿名使用者
vars,t,s1:string;
n,i,j,w,z,w1,z1,w2,z2:longint;
begin
readln(t);
readln(s);
n:=length(s);
for i:=length(t) downto 1 docase t[i] of
'a':begin
for j:=1 to n do
s1:=s1+s[n-j+1];
s:=s1;
s1:='';
end;
'c':begin
for j:=2 to n do
s1:=s1+s[j];
s1:=s1+s[1];
s:=s1;
s1:='';
end;
'e':begin
w:=1;
z:=n div 2;
if n mod 2=0 then beginw1:=z;
z1:=0;
endelse begin
w1:=z+1;
z1:=w1;
end;
w2:=w1+1;
z2:=n;
for j:=w2 to z2 do
s1:=s1+s[j];
for j:=w1 to z1 do
s1:=s1+s[j];
for j:=w to z do
s1:=s1+s[j];
s:=s1;
s1:='';
end;
'j':begin
s1:=s[n];
for j:=1 to n-1 do
s1:=s1+s[j];
s:=s1;
s1:='';
end;
'm':begin
for j:=1 to n do
if s[j] in ['0'..'9']then if s[j]<>'9' then s1:=s1+chr(ord(s[j])+1)
else s1:=s1+'0'
else s1:=s1+s[j];
s:=s1;
s1:='';
end;
'p':begin
for j:=1 to n do
if s[j] in ['0'..'9']then if s[j]<>'0' then s1:=s1+chr(ord(s[j])-1)
else s1:=s1+'9'
else s1:=s1+s[j];
s:=s1;
s1:='';
end;
end;
write(s);
end.
c語言程式設計迷宮問題,c語言程式設計的迷宮
include include include struct stack s 1024 void getmaze int,int int takelmaze int,int void push int,int,int void output int,int int maze 1024 1024 bo...
C語言問題C語言程式設計問題
include include void main 氣泡排序按英語詞典規律排序 for i 1 i 5 i printf the country s after sort is n 排序後的國家名稱 for i 0 i 5 i 這段 經過除錯沒有問題,明天有面試,寫個練練手,祝福我吧 樓上你把注釋寫...
c語言程式設計,C語言程式設計
else 非字母 switch read buf break default break printf n printf tab count d n tab count printf blank count d n blank count printf char count d n char cou...