勇敢追求自己,加油加油
分类: C/C++
2010-12-02 08:54:26
//********************************
#include
//*********************************************
#include
//the contains Header file of input and output
using namespace std;
int main(int argc,char *argv[])//The main function with parameters
{
cout<<"The program file is :"<
for(int k=1;k
cout<<"argv["<
cout<
return 0;
}
//*************************************
#include
using namespace std;
int add(int,int);
double add(double,double);
int main()
{
cout<
cout<
return 0;
}
int add(int x,int y)
{
return x+y;
}
double add(double x,double y)
{
return x+y;
}
//*****************************
#include
using namespace std;
int main()
{
int i;
int sum=0;
i=2;
do
{
sum+=i;
i+=2;
}while(i<100);
cout<<"100yinei suoyou oushu de hewei:"<
return 0;
}
//**********************************************
#include
using namespace std;
int main()
{
int i,j,k,n,m;
for(i=1;i<=9;i++)
{
for(j=0;j<=9;j++)
{
for(k=0;k<=9;k++)
{
n=i*100+j*10+k;
m=i*i*i+j*j*j+k*k*k;
if(n==m)
cout<
}
}
}
cout<
return 0;
}
//************************************
#include
using namespace std;
int main()
{
int bcs,cs;
for(bcs=1;bcs<=9;bcs++)
{
for(cs=1;cs<=bcs;cs++)
{
cout<
}
cout<
}
return 0;
}
//*********************************************
#include
using namespace std;
void print(int a);
void print1(int a);
int main()
{
int n;
cin>>n;
cout<<"Output i-recursive jo: ";
print(n);
cout<
cout<<"output rekursive: ";
print1(n);
cout<
return 0;
}
void print(int a)
{
while(a>0)
cout<
a=a/10;
}
}
void print1(int a)
{
if(a>0)
{
cout<
print1(a/10);
}
}
//*********************************
#include double Add(double a,double b) #include #include #include #define PI 3.1415926 #include #define PI 3.1415926 #define flag 1 #include #include #define MAX(a,b) (a>b)?a:b #include #include #include #include #include #include #include #define SQ(y) (y)*(y) #include #include #include #include #include #include #define PI 3.14159 #include #include #include #include #include #include #include #include #include #include return 0; #include #include #include #include cout<<"*pp= "<<*pp<
using namespace std;
int main()
{
int a[3][3]={1,2,3,4,5,6,7,8,9};
int i=1,j=1;
int (*p)[3];//Pointer points to an array of arrays defined
p=a;
cout<<"*(*(a+i)+j)= "<<*(*(a+i)+j)<
cout<<"*(a[i]+j)= "<<*(a[i]+j)<
cout<<"*(a+i)[j]= "<<*(a+i)[j]<
cout<<"*(a+3*i+j)= "<<*(a+3*i+j)<
cout<<"*(*(p+i)+j)= "<<*(*(p+i)+j)<
cout<<"*(p[i]+j)= "<<*(p[i]+j)<
cout<<"*(p+i)[j]= "<<*(p+i)[j]<
cout<<"*(p+3*i+j)= "<<*(p+3*i+j)<
cout<<"p[i][j]= "<
return 0;
}
//***************************************
{
return a+b;
}
//****************************************
#include "file1.cpp"
using namespace std;
int main()
{
double a;
double b,e,f;
a=3;
b=2;
e=Add(a,2);
f=Add(b+1,2);
cout<<"e="<
return 0;
}
//***********************************************
using namespace std;
int func(int n)
{
if(n>0)
return 1;
else if(n==0)
return 0;
else
return -1;
}
int main()
{
int n;
cout<<"Please input n:"<
cout<<"\nthe result:"<
}
//******************************
using namespace std;
int Fac(int n)
{
if(n<0)
{
cout<<"error!!!"<
}
else if(n<=1)
return 1;
else
return n*Fac(n-1);
}
int main()
{
int Fac(int n);
int n;
cout<<"input n:"<
cout<<"n!="<
}
//**************************
#define S PI*Y*Y
#include
using namespace std;
int main()
{
int Y;
cout<<"Please input the radius:"<
cout< return 0;
}
//***********************************
using namespace std;
int max(int x,int y)
{
return x>y?x:y;
}
int main()
{
int (*p)(int,int);
int a,b,c;
p=max;
cout<<"Please input 2 number:"<
c=(*p)(a,b);
cout<<"max(a,b)= "<
}
//*********************************
#include
using namespace std;
int main()
{
double radius,sr,a,ss;
#ifdef PI
{
cout<<"Please input radius:"<
sr=PI*radius*radius;
cout<<"The circle area is:"<<"\t"<
#else
{
cout<<"Please input a:"<
ss=a*a;
cout<<"the square area is:"<<"\t"<
#endif
return 0;
}
//*****************************************
#include
using namespace std;
int main()
{
#if flag
{
double radius,sr;
cout<<"Please input radius:"<
sr=3.141526*radius*radius;
cout<<"The circle area is:"<<"\t"<
//#error "flag has been defined"
#else
{
double a,ss;
cout<<"Please input a:"<
ss=a*a;
cout<<"The square area is:"<<"\t"<
#endif
return 0;
}
//****************************************
using namespace std;
struct point
{
int x;
int y;
};
int main()
{
point pt;
pt.x=0;
pt.y=1;
cout<<"pt.x= "<
}
//********************************
#include
using namespace std;
int main()
{
int a=1234567890;
double b=123.45;
cout<
}
//*********************************
#include
using namespace std;
int main()
{
int x,y,max;
cout<<"input two numbers: ";
cin>>x>>y;
max=MAX(x,y);
cout<<"max="<
}
//********************************
using namespace std;
const double PI=3.1416;
double fcir_1(double);
double fcir_2(double);
int main()
{
double radius,cir_1,cir_s;
cout<<"Please input radius:"<
cir_1=fcir_1(radius);
cout<<"The week long is :"<<"\t"<
cout<<"The area is :"<<"\t"<
}
double fcir_1(double r)
{
double cir_1;
cir_1=2*PI*r;
return cir_1;
}
double fcir_2(double r)
{
double cir_s;
cir_s=PI*r*r;
return cir_s;
}
//***************************************
using namespace std;
int min(int a,int b);
int min(int a,int b,int c);
int min(int a,int b,int c,int d);
int main()
{
cout<
}
int min(int a,int b)
{
return a;
}
int min(int a,int b,int c)
{
int t=min(a,b);
return min(t,c);
}
int min(int a,int b,int c,int d)
{
int t1=min(a,b);
int t2=min(c,d);
return min(t1,t2);
}
//******************************
using namespace std;
inline int abs(int x)
{
return x<0?-x:x;
}
int main()
{
int a,b=3,c,d=-4;
a=abs(b);
c=abs(d);
cout<<"a="< return 0;
}
//*********************************
using namespace std;
int main()
{
int a,b,num1,num2,temp;
cout<<"Please input numbers:"<
if(num1>num2)
{
temp=num1;
num1=num2;
num2=temp;
}
a=num1;
b=num2;
while(b!=0)
{
temp=a%b;
a=b;
b=temp;
}
cout<<"the Greatest common divisor is:"< cout<<"the LCM is:"<
}
//******************************************
using namespace std;
int main()
{
int a[5]={1,2,3,4,5};
int *p=a;
int i=1;
cout<<"a[i]= "< cout<<"*(a+i)= "<<*(a+i)<
}
//*********************************************
#include
using namespace std;
int main()
{
double a=1.23456789;
cout< cout<
}
//*********************************************
using namespace std;
int main()
{
cout<<"Hello.\n";
return 0;
}
//**********************************************
#include
using namespace std;
int main()
{
int a,sq;
cout<<"input a number: ";
cin>>a;
SQ(a+1);
cout<<"sq="<
}
//****************************************
using namespace std;
int main()
{
int a=5;
int b=3;
int c=1,d=2,e=6;
int res=0;
res=a+b-c/d+e%d;
cout<<"运算结果为:"<
}
//*************************************************
using namespace std;
int main(int argc,char *argv[])
{
const int n=100;
int i,j;
for(i=2;i<=n;i++)
{
int flag=1;
for(j=2;j if(i%j==0)
{
flag=0;
break;
}
if(flag==1)
cout< }
cout<
}
//************************************************
using namespace std;
void swap(int a,int b);
int main()
{
int x=8,y=10;
cout<<"x="<
p4=&a;
int * const p5=&a; //A pointer constant
const int * const p6=&a;//A pointer to a constant pointer constant
cout<<"*p5= "<<*p5<
}
//******************************************
using namespace std;
int main()
{
int i;
int sum=0;
for(i=2;i<=100;i=i+2)
{
sum+=i;
}
cout<<"100以内所有偶数为:"<
}
//*************************************
using namespace std;
int main()
{
int i;
int sum=0;
i=2;
while(i<=100)
{
sum+=i;
i=i+2;
}
cout<<"100 nei suoyou de oushu he wei:"<
}
//*****************************************
#include
using namespace std;
int main()
{
float a,b,c,d;
cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
cout<<"c=";
cin>>c;
d=b*b-4*a*c;
if(a==0)
cout<<"不是一元二次方程"<
{
cout<<"方程有两个实根!"<
else if(d==0)
{
cout<<"方程有一个实根!"<
else
cout<<"方程无实根!!!"<
}
//***************************************
#include
using namespace std;
#define OK 100
void sout(double);
void lout(double);
int main()
{
double radius,s,l;
cout<<"Please input radius: ";
cin>>radius;
s=PI*radius*radius;
sout(s);
l=2*PI*radius;
lout(l);
cout<<"OK"<
}
//#undef PI
void sout(double r)
{
r=PI*r*r;
cout<<"the area is : "<
void lout(double r)
{
cout<<"the long is :"<
//*****************************************
using namespace std;
int main()
{
int a,b;
cin>>a;
cin>>b;
if(a>b)
cout<<"the max number is : "< else
cout<<"the max number is : "< a=1000;
cout<<"默认下: "< cout<<"十进制: "<
}
//***************************************
#define CIR(r) r*r
#define TEST
using namespace std;
int main()
{
int x=1;
int y=2;
int z;
z=CIR(x+y);
cout<<"CIR(x+y)="<
cout<<"x= "<
cout<<"z= "<
}
//****************************************
using namespace std;
struct student
{
int code;
char name[20];
char sex;
int age;
};
struct student stu[2]={{200301,"zhang_san",'m',21},{200302,"li_si",'m',23}};
int main()
{
struct student *pstu;
for(pstu=stu;pstu
cout<
return 0;
}
//;******************************
using namespace std;
void swap(int &a,int &b);
int main()
{
int x=8,y=10;
cout<<"x="<
{
struct student *pstu=&stu;
cout<<"stu.code= "<
}
//*****************************************
#include
using namespace std;
int main()
{
const double Num=123.4567;
cout.flags(ios::right); //设置对齐的标志位为右
cout<
cout.width(12);//显示数据的域宽为12
cout<
cout<
cout.precision(2);
cout<
int n;
cout<<"输入一个八进制整数:";
cin>>oct>>n;
cout<<"八进制整数是:"<
}
//******************************************
using namespace std;
int main()
{
int x=10,result;
double y=8.5;
result=x++;
cout<<"result="<
cout<<"result="<
cout<<"result="<
cout<<"result="<
cout<<"result="<
cout<<"result="<
}
//*********************************
using namespace std;
int s1,s2,s3;
int vs(int a,int b,int c)
{
int v;
b=a*b*c;
s1=a*b;
s2=b*c;
s3=a*c;
return v;
}
int main()
{
int v,l,w,h;
cout<<"Please input length,width and height:"<
v=vs(l,w,h);
cout<<"v= "<
}
//**********************************
using namespace std;
void fn()
{
goto S;
int b;
cin>>b;
if(b>0)
{
S:
goto End;
}
End:
cout<<"Can't input b"<
int main()
{
fn();
return 0;
}
//*******************************************
using namespace std;
void swap(int *,int *);
int main()
{
int a=3,b=4;
cout<<"a="< swap(&a,&b);
cout<<"a="< return 0;
}
void swap(int *x,int *y)
{
int t=*x;
x=y;
*y=t;
cout<<"x="<<*x<
//****************************************
using namespace std;
#include
char *max(char *a,char *b)
{
return strcmp(a,b)?a:b;
}
int main()
{
char *p=max("hello","good");
cout<
}
//******************************************
using namespace std;
int main()
{
int a[5]={1,2,3,5,7};
int (*pa)[5]=&a;//shuzu zhizhen
cout<<"*pa[0]= "<<*pa[0]<
static const char *pb[5]={"Tom","John","Mary","Smith Black","Rose"};
cout<<"pb[0]= "<
}
//***************************************
#include
using namespace std;
int main()
{
char str1[100]="hello ";
static const char *str2="C++";
char *str;
static const char b[]="yuzhou";
cout<<"b= "< cout<<"size0f(b)= "<
cout<<"str2= "<
cout<<"strcat(str1,str2)= "<
cout<<"strcmp(str1,str2)= "< str=strcpy(str1,str2);
cout<<"strcpy(str1,str2)= "<
cout<<"strlen(str1)= "< return 0;
}
//***********************************
using namespace std;
void fun(int &a,int &b)
{
int p;
p=a;
a=b;
b=p;
}
void exchange(int &a,int &b,int &c)
{
if(a {
fun(a,b);
}
if(a
fun(a,c);
}
if(b
fun(b,c);
}
}
int main()
{
int a,b,c;
a=12;
b=639;
c=78;
exchange(a,b,c);
cout<<"a="< return 0;
}
//*****************************
using namespace std;
int main()
{
int a;
int *p=&a,**pp=&p;
a=1;
cout<<"a= "< cout<<"*p= "<<*p<
}
//***************************************************