更新时间2019-01-15 23:01:15
#include<iostream>
#include<iomanip>
#include<math.h>
#include<string>
using namespace std;
enum level{e,f,g,h};
const double PI=3.1415926;
int main()
{
int a;
int z;
int v;
int c;
int b;
unsigned int x;
unsigned int y;
string r;
string e;
string d;
string str1="男",str2="女";
cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
cout<<"a+b= "<<a+b<<endl;
cout<<"a*b= "<<a*b<<endl;
cout<<"a/b= "<<(float)a/b<<endl;
cout<<"b/a= "<<(float)b/a<<endl;
cout<<"a-b= "<<a-b<<endl;
cout<<"b-a= "<<b-a<<endl;
cout<<"a^b= "<<(a^b)<<endl;
cout<<"a&b= "<<(a&b)<<endl;
cout<<"a|b= "<<(a|b)<<endl;
cout<<"a的b次方="<<pow(a,b)<<endl;
cout<<"b的a次方="<<pow(b,a)<<endl;
cout<<"半径为"<<a<<"的圆的面积为: "<<a*a*PI<<endl;
cout<<"半径为"<<b<<"的圆的面积为: "<<b*b*PI<<endl;
cout<<"a的八进制为"<<setbase(8)<<a<<endl;
cout<<"a的十六进制为"<<setbase(16)<<a<<endl;
cout<<"b的八进制为"<<setbase(8)<<b<<endl;
cout<<"b的十六进制为"<<setbase(16)<<b<<endl;
cout<<"半径为"<<a<<"的圆的周长为: "<<a*2*PI<<endl;
cout<<"半径为"<<b<<"的圆的周长为: "<<b*2*PI<<endl;
cout<<"输入你的学期末成绩"<<endl;
cin>>x;
if (500<x&&x<=600)
{cout<<"不错"<<endl;r="聪明";z=2;}
else if (400<x&&x<=500)
{cout<<"看得过去"<<endl;r="一般";z=2;}
else if (0<=x&&x<=300)
{cout<<"太差"<<endl;r="笨";z=2;}
else if (600<x&&x<=810)
{cout<<"棒极了!"<<endl;r="高智商";z=2;}
else
{cout<<"YOU MUST BE KIDDING!"<<endl;r="...";z=1;}
cout<<"你多大了?"<<endl;
cin>>y;
if (0<y&&y<=10)
{cout<<"你是个小盆友"<<endl;e="很小";v=2;}
else if (10<y&&y<=20)
{cout<<"你是个年轻人"<<endl;e="年轻";v=2;}
else if (20<y&&y<=50)
{cout<<"你是个成年人"<<endl;e="中年";v=2;}
else if (50<y&&y<=120)
{cout<<"你是个老年人"<<endl;e="年迈";v=2;}
else if (y>120)
{cout<<"你是个老妖怪"<<endl;e="前所未有";v=2;}
else
{cout<<"..."<<endl;e="...";v=1;}
cout<<"你是男生或女生?(你最好输入“男”或“女”)"<<endl;
if (cin>>str1)
{cout<<"emmm"<<endl;d="男生";c=2;}
else if (cin>>str2)
{cout<<"emmm"<<endl;d="女生";c=2;}
else
{cout<<"..."<<endl;d="...";c=1;}
cout<<"你是一个"<<e<<"的"<<r<<d<<endl;
cout<<c<<z<<v;
return 0;
}
为什么zcv的值一直不变???
会变的,只是你输入的条件不对而已,如以下的
但程序是有问题
因为
if (cin>>str1)
条件始终成立的(你没有判男生/女生)
你没定义zcv