首页 > 编程语言 > 详细

c++

时间:2015-11-21 14:31:11      阅读:279      评论:0      收藏:0      [点我收藏+]

3.7
#include <iostream.h>
void main()

 int a,b;
 a=b=5;
 if(a==1)
  if(b==5)
  { 
   a+=b;
   cout<<a<<endl;
  }
  else
  {
   a-=b;
   cout<<a<<endl;
  }
  cout<<a+b<<endl;
}
3.8

#include <iostream.h>
void main()
{
 float d1,d2;
 char op;
 cout<<"input d1 op d2:";
 cin>>d1>>op>>d2;
 switch(op)
 {
  float temp;
 case ‘+‘:temp=d1+d2;
  cout<<d1<<op<<d2<<"="<<temp<<endl;
  break;
 case ‘-‘:temp=d1-d2;
  cout<<d1<<op<<d2<<"="<<temp<<endl;
  break;
 case ‘*‘:temp=d1*d2;
  cout<<d1<<op<<d2<<"="<<temp<<endl;
  break;
 case ‘/‘:temp=d1/d2;
  cout<<d1<<op<<d2<<"="<<temp<<endl;
  break;
 default:cout<<"error! \n";

 }
}

 

 

本文出自 “青春邓勇” 博客,请务必保留此出处http://dengyong.blog.51cto.com/8409869/1715416

c++

原文:http://dengyong.blog.51cto.com/8409869/1715416

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!