f0512.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //=====================================
- // f0512.cpp
- // 命令解析
- //=====================================
- #include<iostream>
- #include<sstream>
- using namespace std;
- //-------------------------------------
- int main(int argc, char** argv){
- if(argc!=2){
- cout<<"usage: f0512 commandn";
- return 1;
- }
- string s(argv[1]);
- istringstream sin(s);
- int a,b; char c;
- sin>>a>>c>>b;
- switch(c){
- case'-': b=-b;
- case'+': cout<<a+b; break;
- case'*': cout<<a*b; break;
- case'/': cout<<a/b; break;
- default: cout<<"error";
- }
- }//====================================