胡言亂語:
找弧長和弦長的公式找好久喔 ... 再次要在code book加上新東西了XD
這題我犯的錯誤是,忘記輸出小數點後6位,輸出小數的話用printf 比較好寫
double x;
printf("%.nlf",x);
這樣就可以輸出小數點後n位了。=)
程式碼:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<cmath> | |
#include<cstdio> | |
using namespace std; | |
int main(){ | |
double s,a; | |
string str; | |
while(cin>>s>>a>>str){ | |
if(str[0]=='m') a/=60; | |
if(a>180) a=360-a; | |
s+=6440; | |
printf("%.6lf %.6lf\n",a*acos(-1.0)/180.0*s,2.0*s*sin(a*acos(-1.0)/180.0/2.0)); | |
} | |
} |
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。