用函数不用担心精度的损失
#include<iostream> using namespace std; int main() { float a = 3.123456,b = 1234567.000000; swap(a,b); cout<<fixed; cout<<a<<"->"<<b<<endl; return 0; }
#include<iostream> #include<string> using namespace std; int main() { string a ="666",b = "999"; swap(a,b); cout<<a<<"->"<<b<<endl; return 0; }
文章评论