|
|
вернуться в форумwhat is wrong?! hi all! what is wrong with this code? #include <iostream> #include <cmath> #include <vector> using namespace std; int ragham(double x) { int z=0,num; num=int(x); for(int i=1;num>0;i++) { num/=10; z=i; } return z; } int main() { vector <long double> a; double b,c; int j=0,g; long double u; while(cin>>u) { a.push_back(u); j++; } for(int i=j-1;i>=0;i--) { b=sqrt(a[i]); c=int((b-int(b))* int(pow(10.0,4))); if(c!=0) { if(ragham(c)==3) cout<<int(b)<<".0"<<int((b-int(b))*pow(10.0,4))<<endl; else if(ragham(c)==2) cout<<int(b)<<".00"<<int((b-int(b))*pow(10.0,4))<<endl; else if(ragham(c)==1) cout<<int(b)<<".000"<<int((b-int(b))*pow(10.0,4))<<endl; else if(ragham(c)==4) cout<<int(b)<<'.'<<int((b-int(b))*pow(10.0,4))+1<<endl; } else cout<<b<<".0000"<<endl; } return 0; } --------------------- according to the code,i think you surely understood that i am a freshman!:) Edited by author 18.11.2010 00:13 Edited by author 18.11.2010 00:14 Edited by author 18.11.2010 12:00 |
|
|