回 帖 发 新 帖 刷新版面

主题:[讨论]特急!相当急!求答案!答对给加分!

1.计算下列各式的值。
  (1)1+2+4+8+......+128+256+512+1024
  (2)1+(1+2)+(1+2+3)+......+(1+2+3+4+n)
2.输入一个正整数N,把它分解成质因子相乘的形势。(如:36=1*2*2*3*3,19=1*19)
3.输入年月日,输出该天是星期几(星期几用英文)。

[em10][em10][em10][em10][em10][em10][em10][em10][em10][em10]

回复列表 (共7个回复)

沙发

大家帮帮忙!

板凳

1:
program xtt;
  var
    n:integer;
  function t(a1,an,step:integer):integer;
    var
      i,sum:integer;
  begin
    i:=a1;sum:=0;
    for i:=a1 to an do begin
      sum:=sum+i;
      i:=i+step-1;
    end;
    t:=sum;
  end;
  function s(n:byte):integer;
    var
      i,sum:integer;
  begin
    sum:=0;
    for i:=1 to n do sum:=sum+t(1,i,1);
    s:=sum;
  end;
begin
  writeln(t(1,1024,2));
  write('n:');readln(n);
  writeln(s(n));
  readln;
end.

3 楼

2:
program xtt;
  var
    i,n:word;f:boolean;
begin
  write('N=');readln(n);
  i:=2;f:=false;
  while i<=n do
    if n mod i=0 then begin
      if f then write('*',i) else write(i);
      n:=n div i;
      f:=true;
    end else inc(i);
  readln;
end.

4 楼

3:
program xtt;
  uses dos;
  const
    s:array[1..7] of string
     =('星期一','星期二','星期三','星期四','星期五','星期六','星期日');
{亦可改成英文,但我不会拼}
  var
    n0,y0,r0,n,y,r,x:word;
begin
  readln(n,y,r);
  getdate(n0,y0,r0,x);
  setdate(n,y,r);
  getdate(n,y,r,x);
  setdate(n0,y0,r0);
  write(s[x]);readln
end.

5 楼

第一题
var
  i,j,p,s:longint;
begin
  p:=1;
  for i:=1 to 11 do
    begin
    s:=s+p;
    p:=p*2;
    end;
  writeln('1+2+4+8+16+32+64+128+256+512+1024=',s);
end.
第二小题
var
  n,i,j,p:integer;
begin
  read(n);
  for i:=1 to n do
    for j:=1 to i do
      p:=p+j;
  writeln(p);
end.
第二题
var
  m,i:integer;
begin
  read(m);i:=2;
  write(m,'=1');
  while i<=m do
  if m mod i=0
  then begin
  write('*',i);
  m:=m div i;
  end
  else begin
  inc(i);
  end;
  writeln;
end.

6 楼

1(1):
var a,b:integer;
begin
  a:=1;b:=0;
   repeat
    inc(b,a);a:=a*2;
   until a>1024;
  writeln(b);
end.
1(2):
var n,i,sum:integer;
begin
  read(n);sum:=0;
  for i:=1 to n do
   inc(sum,(1+i)*i div 2);
  writeln(sum);
end.
2:
var a,b:integer;
begin
  read(a);b:=1;
  write(a,'=1*');
   repeat
    inc(b);
    while a mod b=0 do
     begin
      write(b);a:=a div b;
      if a<>1 then write('*');
     end;
   until a=1;
  writeln;
end.
3:
const max=10000;
      z:array[1..12]of integer=(31,max,31,30,31,30,31,31,30,31,30,31);
var y,m,d,i,sum:integer;
function ry(n:integer):boolean;
begin
  if ((n mod 4=0)and(n mod 100<>0))or(n mod 400=0) then ry:=true
  else ry:=false;
end;
begin
read(y,m,d);sum:=0;
for i:=1 to y-1 do
  if ry(i) then inc(sum,366 mod 7)
  else inc(sum,365 mod 7);
for i:=1 to m-1 do
  if i<>2 then inc(sum,z[i] mod 7)
  else begin
        if ry(y) then inc(sum,29 mod 7)
        else inc(sum,28 mod 7);
       end;
  inc(sum,d mod 7);
  sum:=sum mod 7;
  case sum of
   1:writeln('Monday');
   2:writeln('Tuesday');
   3:writeln('Wednesday');
   4:writeln('Thursday');
   5:writeln('Friday');
   6:writeln('Saturday');
   0:writeln('Sunday');
  end;
end.

7 楼

第三题有公式!

我来回复

您尚未登录,请登录后再回复。点此登录或注册