|  | 
|  | 
| back to board | why it doesn't work??? help to write on c++! #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++! Вот на основе твоего кода. массив 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--]);
 }
 | 
 | 
|