如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。

URAL/1001/C++

来自"NOCOW"

< URAL | 1001(跳转自URAL/1001)
跳转到: 导航, 搜索
#include <iostream>
#include <math.h>
 
using namespace std;
 
long long i,j=0;
double a[100000000];
double x;
 
int main ()
{
    while (cin>>i)
          {
          a[j]=sqrt((double)(i));
          j++;
          }
    for (i=j-1;i>=0;i--)
        {
        x=(long long)(a[i]*10000+0.5)/10000;
        printf ("%0.4lf\n",a[i]);
        }
    return (0);
}
program ural1001;
var i,j:longint;
    a:array[1..1000000]of int64;
begin
  while not(seekeof)do
  begin
    inc(i);
    read(a[i]);
  end;
  for j:=i downto 1 do writeln(sqrt(a[j]):0:4);
end.
//------------------下面的程序太复杂--------------------------------
TYPE
  node=^Tnode;
  Tnode=Record
    data:Extended;
    next:node;
  END;
VAR
  n:Qword;
  k:Extended;
  list,temp:node;
BEGIN
  new(list);
  list^.next:=nil;
    while not seekeof do
      BEGIN
        read(n);
        k:=sqrt(n);
        new(temp);
        temp^.data:=k;
        temp^.next:=list^.next;
        list^.next:=temp;
      END;
    while list^.next<>nil do
      BEGIN
        writeln(list^.next^.data:0:4);
        list^.next:=list^.next^.next;
      END;
END.

PASCAL 字符读入(10^18...不知道楼上longint怎么会过。。)

var
a:array[0..1000000] of real;
n,s:real;m,i:longint;ch:char;
begin
while true do begin 
		read(ch); while (not (ch in ['0'..'9'])) and not (eof) do read(ch);
		if ch in ['0'..'9'] then 
		begin 
		  n:=ord(ch)-48; 
		  read(ch); 
		  while (ch in ['0'..'9']) do begin n:=n*10+ord(ch)-48; read(ch); end;
		  inc(m);a[m]:=sqrt(n);
	        end
		    else break;
	      end;
for 	i:=m downto 1 do writeln(a[i]:0:4);	
end.
个人工具