返回列表 發帖

104 基本認識-浮點數總和

1. 題目說明:
請依下列題意進行作答,使輸出值符合題意要求。

2. 設計說明:
請撰寫一程式,讓使用者輸入兩個浮點數計算兩浮點數之總和(四捨五入至小數點後第二位)

提示:若使用 Java 語言答題,請以「JP」開頭命名包含 main 靜態方法的 class,評測系統才能正確評分。

3. 輸入輸出:
輸入說明
兩個浮點數

輸出說明
計算總和(四捨五入至小數點後第二位)

範例輸入
2.222
3.666

範例輸出
total=5.89

本帖隱藏的內容需要回復才可以瀏覽

  1. 1
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     float a,b;

  7.     cin>>a>>b;
  8.     printf("total=%.2f",a+b);

  9.     return 0;
  10. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;

  3. int main()
  4. {
  5.     float a,b;
  6.     cin>>a>>b;
  7.     printf("total=%.2f",(a+b));
  8.     return 0;
  9. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;

  4. int main()
  5. {
  6.    float a,b,d;
  7.    cin>>a;
  8.    cin>>b;
  9.    d=a+b;
  10.    printf("total=%.2f",d);
  11. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     cin.sync_with_stdio(0);
  6.     float a=0,b=0;
  7.     cin>>a;
  8.     cin>>b;
  9.     float c;
  10.     c=a+b;
  11.     printf("total=%.2f",c);
  12. return 0;
  13. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         double a,b;
  7.         cin>>a>>b;
  8.         printf("total=%.2f",a+b);
  9.         return 0;
  10. }
複製代碼

TOP

  1. #include<bits/stdc++.h>

  2. using namespace std;
  3. int main()
  4. {
  5.     double a,b;
  6.     cin>>a>>b;
  7.    
  8.     printf("total=%.2f",(a+b));
  9.       
  10.     return 0;        
  11. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     double a,b;
  7.     cin>>a>>b;
  8.     printf("total=%.2f",a+b);
  9.     system("pause");
  10.     return 0;
  11. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.    double a,b;
  7.    cin>>a>>b;
  8.    printf("total=%.2f",(a+b));

  9.     system("pause");
  10.     return 0;
  11. }
複製代碼

TOP

5

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;

  3. main(){
  4.         double a,b;
  5.         cin>>a>>b;
  6.     printf("total=%.2f",a+b);
  7.        
  8.         system("pause");
  9.     return 0;
  10. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.         float a,b;
  6.         cin>>a>>b;
  7.         printf("total=%.2f",a+b);
  8.         return 0;
  9. }
複製代碼

TOP

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.         double a,b;
  6.         cin>>a>>b;
  7.         cout<<"total="<<a+b<<endl;
  8.         printf("total=%.2f",a+b);
  9.         return 0;
  10. }
複製代碼

TOP

  1. #include<bits/stdc++.h>

  2. using namespace std;
  3. int main()
  4. {
  5.     double a,b;
  6.     cin>>a>>b;
  7.    
  8.     printf("total=%.2f",(a+b));
  9.       
  10.     return 0;        
  11. }
複製代碼
陳牧謙

TOP

  1. #include<bits/stdc++.h>

  2. using namespace std;
  3. int main()
  4. {
  5.     double a,b;
  6.     cin>>a>>b;
  7.    
  8.     printf("total=%.2f",(a+b));
  9.       
  10.     return 0;        
  11. }
複製代碼

TOP

返回列表