ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

why it doesn't work??? help to write on c++!
Posted by Ilya_novichok 10 Jul 2013 17:15
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double *n = new double[1000];
double *m = new double[1000];
int l=0;
int r=0;
while(getchar() != EOF)
{
scanf("%lf",&n[l]);
l++;
}
for(r=l; r>0; r--)
{
m[r]=sqrt(n[r]);
cout << m[r];
}
}
Re: why it doesn't work??? help to write on c++!
Posted by Alexander 15 Jul 2013 18:05
Вот на основе твоего кода. массив m мне кажется лишний здесь. getchar "съедал" символ.
cout выводит без заданной точности.
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double *n = new double[10000000];
double buf;
int l=0;
while(scanf("%lf",&buf) != EOF) n[l++]= sqrt(buf);
l-=1;
while (l>=0) printf("%.4f\n",n[l--]);
}