#include <iostream>
using namespace std;
float sum(float a,float b);
float subs(float a, float b);
float multiple(float a, float b);
float division(float a, float b);
int main()
{//main
int a,b;
char o ;
cout<<"input your calculation with operation (+,-,/,*) such as 5+6 : /n ";
cin >> a >> o >> b ;
switch('o')
{
case '+':
sum(float a, float b);
break;
case '-':
subs(float a, float b);
break;
case '*':
multiple(float a, float b);
break;
case '/':
division(float a, float b);
break;
default :
cout << "error, try again " <<endl;
}
return 0;
}//main
float sum(float a,float b)
{//sum
float total= a+b;
return total;
}//sum
float subs(float a, float b)
{//subs
float total=a-b;
return total;
}//subs
float multiple(float a, float b)
{//multiple
float total=a*b;
return total;
}//multiple
float division(float a, float b)
{//division
float total=a/b;
-5
A
回答
7
從表面上看,最後缺少一個大括號。在操作上,您的switch語句打開一個常量'o',而不是變量o。
+0
編譯器表示第18,23,28,33行有錯誤: 函數main()中的表達式語法 – Quark92 2011-04-26 15:43:12
0
變化:
switch('o')
到
switch(o)
相關問題
- 1. 我的代碼有什麼問題?
- 2. 我的mouseup代碼有什麼問題?
- 3. 我的onStart代碼有什麼問題?
- 4. 我的X11代碼有什麼問題?
- 5. 我的php代碼有什麼問題?
- 6. 我的PHP代碼有什麼問題?
- 7. 我的代碼有什麼問題?
- 8. 我的代碼有什麼問題?
- 9. 我的arduino代碼有什麼問題?
- 10. 我的代碼有什麼問題?
- 11. 我的AJAX代碼有什麼問題
- 12. 我的SceneJS代碼有什麼問題?
- 13. 我的代碼有什麼問題? 9
- 14. 我的Python代碼有什麼問題
- 15. 我的C++代碼有什麼問題?
- 16. xmlpullparser(),我的代碼有什麼問題?
- 17. 我的JavaScript代碼有什麼問題?
- 18. 我的代碼有什麼問題?
- 19. 我的C#代碼有什麼問題?
- 20. 我的代碼有什麼問題? countocolsonant
- 21. 我的php代碼有什麼問題?
- 22. 我的css代碼有什麼問題
- 23. 我的ftp代碼有什麼問題?
- 24. 我的python代碼有什麼問題?
- 25. 我的flash代碼有什麼問題?
- 26. 我的JTree代碼有什麼問題?
- 27. 我的代碼有什麼問題....?
- 28. 我的.htaccess代碼有什麼問題?
- 29. 我的Haskell代碼有什麼問題?
- 30. 我的js代碼有什麼問題?
做什麼你的代碼的一部分,並不如預期的作品?這是功課嗎? – 2011-04-26 14:25:03
我不知道。你的代碼有哪些*錯誤? (它是編譯器錯誤,運行時崩潰還是別的?) – 2011-04-26 14:25:28
一個猜測:我沒有看到任何可以顯示或以其他方式使用操作結果的東西。函數的返回值被忽略。你打算打印結果嗎? – 2011-04-26 14:49:26