×
解除綁定,重新設定系統帳號的密碼
您的系統帳號 ID:
您的系統帳號:
您的帳號暱稱:
設定新密碼:
設定新密碼:
×
請輸入要加入的「課程代碼」
請向開設課程的使用者索取「課程代碼」
分類題庫
解題動態
排行榜
討論區
競賽區
登入
註冊
發表新討論
#561: 請問這題CE
luckysky
(luckysky)
學校 : 國立中央大學
編號 : 2338
×
傳送站內訊息
傳給:
主題:
內容:
來源 : [140.115.217.26]
最後登入時間 :
2008-12-01 22:51:05
c092.
00587 - There's treasure everywhere!
--
UVa
587
| From: [61.229.83.173] | 發表日期: 2008-09-09 22:35
編譯錯誤, 請檢查語法是否符合系統所支援的編譯器的要求。
錯誤訊息:
/tmp/code_45323.cpp: In function `int main(int, char**)':
/tmp/code_45323.cpp:41: error: call of overloaded `sqrt(int)' is ambiguous
/usr/include/bits/mathcalls.h:157: error: candidates are: double sqrt(double)
/usr/include/c++/3.3/cmath:550: error: long double
std::sqrt(long double)
/usr/include/c++/3.3/cmath:546: error: float std::sqrt(float)
/tmp/code_45323.cpp:44: error: call of overloaded `sqrt(int)' is ambiguous
/usr/include/bits/mathcalls.h:157: error: candidates are: double sqrt(double)
/usr/include/c++/3.3/cmath:550: error: long double
std::sqrt(long double)
/usr/include/c++/3.3/cmath:546: error: float std::sqrt(float)
/tmp/code_45323.cpp:47: error: call of overloaded `sqrt(int)' is ambiguous
/usr/include/bits/mathcalls.h:157: error: candidates are: double sqrt(double)
/usr/include/c++/3.3/cmath:550: error: long double
std::sqrt(long double)
/usr/include/c++/3.3/cmath:546: error: float std::sqrt(float)
/tmp/code_45323.cpp:50: error: call of overloaded `sqrt(int)' is ambiguous
/usr/include/bits/mathcalls.h:157: error: candidates are: double sqrt(double)
/usr/include/c++/3.3/cmath:550: error: long double
std::sqrt(long double)
/usr/include/c++/3.3/cmath:546: error: float std::sqrt(float)
#562: Re:請問這題CE
luckysky
(luckysky)
學校 : 國立中央大學
編號 : 2338
×
傳送站內訊息
傳給:
主題:
內容:
來源 : [140.115.217.26]
最後登入時間 :
2008-12-01 22:51:05
c092.
00587 - There's treasure everywhere!
--
UVa
587
| From: [61.229.83.173] | 發表日期: 2008-09-09 22:36
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int
f(
char
c){
if(c=='N' || c=='S' || c=='W' || c=='E'){
return 1;
}
else{
return 0;
}
}
int
main(
int
argc,
char
*argv[])
{
char
a[300];
double
N=0,S=0,W=0,E=0,ans;
int
temp=0,T=0;
bool
kk;
while(cin>>a){
if(a[0]=='E' && a[1]=='N' && a[2]=='D' && a[3]=='\0'){
break;
}
T++;
kk=false;
N=0;
S=0;
W=0;
E=0;
for(
int
i=0;i<strlen(a)-1;i++){
if(a[i]>='0' && a[i]<='9'){
temp*=10;
temp+=a[i]-'0';
kk=true;
}
else if(kk==true){
if(f(a[i+1])==1){
if(a[i+1]=='N' || a[i]=='N' ){
N+=temp/sqrt(2);
}
if(a[i+1]=='S' || a[i]=='S' ){
S+=temp/sqrt(2);
}
if(a[i+1]=='W' || a[i]=='W' ){
W+=temp/sqrt(2);
}
if(a[i+1]=='E' || a[i]=='E' ){
E+=temp/sqrt(2);
}
}
else{
if(a[i]=='N'){
N+=temp;
}
if(a[i]=='S'){
S+=temp;
}
if(a[i]=='W'){
W+=temp;
}
if(a[i]=='E'){
E+=temp;
}
}
kk=false;
temp=0;
}
}
E-=W;
N-=S;
ans=E*E+N*N;
ans=sqrt(ans);
cout.precision(3);
if(T!=1){
cout<<endl;
}
cout<<"Map #"<<T<<endl;
cout<<"The treasure is located at ("<<fixed<<E<<","<<fixed<<N<<")."<<endl;
cout<<"The distance to the treasure is "<<fixed<<ans<<"."<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
感謝幫看
#565: Re:請問這題CE
POOHccc
()
學校 : 國立臺中技術學院
編號 : 1139
×
傳送站內訊息
傳給:
主題:
內容:
來源 : [220.135.97.253]
最後登入時間 :
2012-02-04 21:23:42
c092.
00587 - There's treasure everywhere!
--
UVa
587
| From: [220.135.97.253] | 發表日期: 2008-09-10 08:30
sqrt(2)請改成sqrt(2.0)或是sqrt((double)2)
另外system("pause")也請拿掉
#577: Re:請問這題CE
luckysky
(luckysky)
學校 : 國立中央大學
編號 : 2338
×
傳送站內訊息
傳給:
主題:
內容:
來源 : [140.115.217.26]
最後登入時間 :
2008-12-01 22:51:05
c092.
00587 - There's treasure everywhere!
--
UVa
587
| From: [140.115.217.26] | 發表日期: 2008-09-14 08:53
sqrt(2)請改成sqrt(2.0)或是sqrt((double)2)
另外system("pause")也請拿掉
3QQ