c++源码基础(反思02)
时间:2010-12-01 来源:yuzhou133
//***************************************
#include <iostream>
using namespace std;
int main(){
int a=0;
int b=0;
a++;
b++;
cout<<"a="<<a<<","<<"b="<<b<<endl;
{
float a=0.5;
a++;
b++;
cout<<"a="<<a<<","<<"b="<<b<<endl;
}
a++;
b++;
cout<<"a="<<a<<"b="<<b<<endl;
return 0;
}
//****************************************
#include <iostream>
using namespace std;
int main()
{
double flag;
flag=true;
cout<<"flag= "<<flag<<endl;
return 0;
}
//*******************************************
#include <iostream>
using namespace std;
int main()
{
char ch1;
ch1='a';
cout<<"ch1= "<<ch1<<endl;
int ch2;
ch2='a';
cout<<"ch2= "<<ch2<<endl;
return 0;
}
//*********************************************
#include <iostream>
using namespace std;
int main()
{
double a;
a=3.14159265;
cout<<"a= "<<a<<endl;
return 0;
}
//****************************************
#include <iostream>
using namespace std;
int main()
{
const double pi=3.141592635898;
const double radius=8.5;
cout<<"area of circle of radius:"<<radius<<" is "<<pi*radius*radius<<"\n";
cout<<"niihao"<<"\n";
return 0;
}
//****************************************
#include <iostream>
using namespace std;
int main()
{
char ch;
ch='a';
int i;
i=(int)ch;
cout<<"ch= "<<ch<<endl;
cout<<i<<endl;
return 0;
}
//****************************************
#include <iostream>
using namespace std;
int main()
{
char ch;
ch='a';
int i=ch;
cout<<"ch= "<<ch<<endl;
cout<<"i= "<<i<<endl;
return 0;
}
//***************************************
#include <iostream>
using namespace std;
int main()
{
const double pi=3.141592635898;
double radius;
double area;
cout<<"please input radius:"<<endl;
cin>>radius;
area=pi*radius*radius;
cout<<"area of radius:"<< radius<<" is "<<area<<"\n";
return 0;
}
//*********************************************
#include <iostream>
using namespace std;
#define M -1
int main()
{
int x,y;
cout<<"请输入一个整数:"<<endl;
cin>>x;
char c;
c="\41";
if(x<M)
{
y=M*x+1;
}
else
y=(x+M)*x-3;
cout<<"x= "<<x<<endl;
cout<<"y= "<<y<<endl;
printf("%d\n",c);
return 0;
}
//*****************************************