Chinaunix首页 | 论坛 | 博客
  • 博客访问: 127179
  • 博文数量: 22
  • 博客积分: 1126
  • 博客等级: 少尉
  • 技术积分: 282
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-22 23:01
个人简介

勇敢追求自己,加油加油

文章分类

全部博文(22)

文章存档

2011年(1)

2010年(21)

我的朋友

分类: C/C++

2010-12-02 08:54:26

//********************************

#include


using namespace std;

int main()

{

int a,b,m=3,n=4;

a=7*2+-3%5-4/3;

b=(m++)-(--n);

cout<
return 0;

}

//*********************************************

#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

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;

}
//***************************************

double Add(double a,double b)

{

return a+b;

}
//****************************************

#include

#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;

}
//***********************************************

#include
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:"< cin>>n;
cout<<"\nthe result:"< return 0;
}
//******************************

#include
using namespace std;
int Fac(int n)
{
if(n<0)
{
cout<<"error!!!"< return -1;
}
else if(n<=1)
return 1;
else
return n*Fac(n-1);
}
int main()
{
int Fac(int n);
int n;
cout<<"input n:"< cin>>n;
cout<<"n!="< return 0;
}
//**************************

#define PI 3.1415926
#define S PI*Y*Y
#include
using namespace std;
int main()
{
int Y;
cout<<"Please input the radius:"< cin>>Y;
cout< return 0;
}
//***********************************

#include
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:"< cin>>a>>b;
c=(*p)(a,b);
cout<<"max(a,b)= "< return 0;
}
//*********************************

#define PI 3.1415926
#include
using namespace std;
int main()
{
double radius,sr,a,ss;
#ifdef PI
{
cout<<"Please input radius:"< cin>>radius;
sr=PI*radius*radius;
cout<<"The circle area is:"<<"\t"< }
#else
{
cout<<"Please input a:"< cin>>a;
ss=a*a;
cout<<"the square area is:"<<"\t"< }
#endif
return 0;
}
//*****************************************

#define flag 1
#include
using namespace std;
int main()
{
#if flag
{
double radius,sr;
cout<<"Please input radius:"< cin>>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:"< cin>>a;
ss=a*a;
cout<<"The square area is:"<<"\t"< }
#endif
return 0;
}
//****************************************

#include
using namespace std;
struct point
{
int x;
int y;
};
int main()
{
point pt;
pt.x=0;
pt.y=1;
cout<<"pt.x= "< cout<<"pt.y= "< return 0;
}
//********************************

#include
#include
using namespace std;
int main()
{
int a=1234567890;
double b=123.45;
cout< cout< cout< cout< cout< return 0;
}
//*********************************

#define MAX(a,b) (a>b)?a:b
#include
using namespace std;
int main()
{
int x,y,max;
cout<<"input two numbers: ";
cin>>x>>y;
max=MAX(x,y);
cout<<"max="< return 0;
}
//********************************

#include
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:"< cin>>radius;
cir_1=fcir_1(radius);
cout<<"The week long is :"<<"\t"< cir_s=fcir_2(radius);
cout<<"The area is :"<<"\t"< return 0;
}
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;
}
//***************************************

#include
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< cout< cout< return 0;
}
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);
}
//******************************

#include
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;
}
//*********************************

#include
using namespace std;
int main()
{
int a,b,num1,num2,temp;
cout<<"Please input numbers:"< cin>>num1>>num2;
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:"< return 0;
}
//******************************************

#include
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)< cout<<"*(p+i)="<<*(p+i)< return 0;
}
//*********************************************

#include
#include
using namespace std;
int main()
{
double a=1.23456789;
cout< cout< cout< return 0;
}
//*********************************************

#include
using namespace std;
int main()
{
cout<<"Hello.\n";
return 0;
}
//**********************************************

#define SQ(y) (y)*(y)
#include
using namespace std;
int main()
{
int a,sq;
cout<<"input a number: ";
cin>>a;
SQ(a+1);
cout<<"sq="< return 0;
}
//****************************************

#include
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<<"运算结果为:"< cout<<"now output the result"< cout<<"int"< cout< cout<<"char"< return 0;
}
//*************************************************

#include
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< return 0;
}
//************************************************

#include
using namespace std;
void swap(int a,int b);
int main()
{
int x=8,y=10;
cout<<"x="< return 0;
}
//*************************************

#include
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:"< return 0;
}
//*****************************************

#include
#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<<"不是一元二次方程"< else if(d>0)
{
cout<<"方程有两个实根!"< cout<<"x1="<<(-b+sqrt(d))/(2*a)< cout<<"x2="<<(-b-sqrt(d))/(2*a)< }
else if(d==0)
{
cout<<"方程有一个实根!"< cout<<"x1=x2="<<(-b)/(2*a)< }
else
cout<<"方程无实根!!!"< return 0;
}
//***************************************

#define PI 3.14159
#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"< cout< return 0;
}
//#undef PI
void sout(double r)
{
r=PI*r*r;
cout<<"the area is : "<}
void lout(double r)
{
cout<<"the long is :"<}
//*****************************************

#include
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<<"十进制: "< cout<<"八进制: "< cout<<"十六进制: "< return 0;
}
//***************************************

#include
#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)="< #ifdef TEST
cout<<"x= "< #endif
cout<<"z= "< return 0;
}
//****************************************

#include
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<code<<"\t"<name<<"\t"<sex<<"\t"<age< }
return 0;
}
//;******************************

#include
using namespace std;
void swap(int &a,int &b);
int main()
{
int x=8,y=10;
cout<<"x="<int main()
{
struct student *pstu=&stu;
cout<<"stu.code= "< cout<<"pstu->code= "<code< cout<<"(*pstu).code= "<<(*pstu).code< return 0;
}
//*****************************************

#include
#include
using namespace std;
int main()
{
const double Num=123.4567;
cout.flags(ios::right); //设置对齐的标志位为右
cout< cout.fill('*');//填充字符'*'
cout.width(12);//显示数据的域宽为12
cout< cout.precision(4);//浮点数的有效个数4
cout< cout.setf(ios::showpos);//显示正号
cout.precision(2);
cout< cout.unsetf(ios::showpos);
int n;
cout<<"输入一个八进制整数:";
cin>>oct>>n;
cout<<"八进制整数是:"< cout<<"对应的十进制整数是:"< cout<<"对应的十六进制整数是:"< return 0;
}
//******************************************

#include
using namespace std;
int main()
{
int x=10,result;
double y=8.5;
result=x++;
cout<<"result="< result=x--;
cout<<"result="< result=x>y;
cout<<"result="< result=x>0&&y<0;
cout<<"result="< result=!x || y<1;
cout<<"result="< result=(x++,y+=x,x-y);
cout<<"result="< return 0;
}

//*********************************

#include
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:"< cin>>l>>w>>h;
v=vs(l,w,h);
cout<<"v= "< cout<<"s1= "< cout<<"s2= "< cout<<"s3= "< return 0;
}
//**********************************

#include
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;
}
//*******************************************

#include
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< cout<<"y="<<*y<}
//****************************************

#include
using namespace std;
#include
char *max(char *a,char *b)
{
return strcmp(a,b)?a:b;
}
int main()
{
char *p=max("hello","good");
cout< return 0;
}
//******************************************

#include
using namespace std;
int main()
{
int a[5]={1,2,3,5,7};
int (*pa)[5]=&a;//shuzu zhizhen
cout<<"*pa[0]= "<<*pa[0]< cout<<"*(pa[0]+1)= "<<*(pa[0]+1)< cout<<"*(pa[1])= "<<*pa[1]< //**************************************************************
static const char *pb[5]={"Tom","John","Mary","Smith Black","Rose"};
cout<<"pb[0]= "< cout<<"pb[1]= "< return 0;
}
//***************************************

#include
#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<<"sizeof(str2)= "< int i=0;
cout<<"str2= "< str=strcat(str1,str2);
cout<<"strcat(str1,str2)= "< i=strcmp(str1,str2);
cout<<"strcmp(str1,str2)= "< str=strcpy(str1,str2);
cout<<"strcpy(str1,str2)= "< i=strlen(str1);
cout<<"strlen(str1)= "< return 0;
}
//***********************************

#include
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;
}
//*****************************

#include
using namespace std;
int main()
{
int a;
int *p=&a,**pp=&p;
a=1;
cout<<"a= "< cout<<"*p= "<<*p< cout<<"p= "< cout<<"*pp= "<<*pp< cout<<"**pp= "<<**pp< return 0;
}
//***************************************************

阅读(1340) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~