初学c++
看了兩章不到。。隨意記錄下。
#include<iostream> #include<string> using std::cout; using std::endl; double calculation(double a,double b,char op) {switch(op){case '+': return a+b;case '-':return a-b;case '*':return a*b;case '/':return a/b;}}double num=0;double num2=0;char op='a'; int main() {////int num=2;//cout<<test();//std::cin>>::num;//cout<<num;//std::string wenzi="hhaha";//cout<<wenzi;cout<<"不科學計算器\n請輸入兩個數字\n請輸入第一個數\n";std::cin>>::num;cout<<"請輸入第二個數\n";std::cin>>::num2;cout<<"請輸入運算符 +,-,*,/\n";std::cin>>op;cout<<"您的結果為:\n";cout<<calculation(num,num2,op);return 0;//退出這個程序 }其實最主要的是在群里學到了一個有意思的東西 就是?
include<string> 原來在c++里面不能直接使用string類型,后來想通,string是引用類型。。轉載于:https://www.cnblogs.com/minCS/archive/2013/03/12/2955967.html
總結
- 上一篇: HTTP 错误 404.2 - Not
- 下一篇: 《OpenCV算法精解——基于Pytho