hdoj2001

 
#include <iostream>
#include<cmath>
 #include <iomanip>
using namespace std;
int main() {
      float  x1,x2,y1,y2,count;
       while(cin >> x1>>y1>>x2>> y2)
       {
           count = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
           cout <<setprecision(2) << setiosflags(ios::fixed | ios::showpoint)<<count<<endl ;
       }
      return 0;
}

注意C++输入输出

// 一、輸出保留小數點後3位
float fn = 3.5004;
cout << setprecision(3) << setiosflags(ios::fixed | ios::showpoint) // 灰色可省去,效果同。
<< fn << endl;

// 二、輸出最多保留3位有效數字
float fn = 3.101;
cout << setprecision(3) << setiosflags(ios::showpoint) // 灰色添加,則後面補充零,直至滿足有效位數,當保留的有效數字恰好到個位數為止,則後面仍顯示小數點。
<< fn << endl;

posted @ 2012-11-06 14:59  茉莉花茶  阅读(150)  评论(0)    收藏  举报