当前位置:文档之家› C++程序设计编程实例大全

C++程序设计编程实例大全

cout<<"c de shuzu zhong min zhi wei:"<<min(c,6)<<endl;
}
/* Note:Your choice is C IDE */
#include <iostream.h>
#define PI 3.1415926535
#define CS Circle_Square
cin>>s;
t="I like programming!";
cout<<"zifuchuan output:"<<endl<<s<<endl<<t<<endl;
cout<<s.append(" OK!")<<endl;
}
/* Note:Your choice is C IDE */
#include <iostream>
}
/* Note:Your choice is C IDE */
#include <iostream>
using namespace std;
void swap(int &x,int &y);
void main()
{
int x=5,y=6;
cout<<"before swap, x:"<<x<<" ,y:"<<y<<endl;
sum=x+y;
return sum;
}
int add(int x,int y,int z)
{
int sum;
sum=x+y+z;
return sum;
}
void main()
{
int a,b;
a=add(5,10);
b=add(5,10,20);
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
}
/* Note:Your choice is C IDE */
#include <iostream.h>
template<class T>
T min(T a[],int n)
{
int i;
T minv=a[0];
for(i=1;i<n;i++)
if(minv>a[i])
minv=a[i];
return minv;
template<class T>
double Circle_Square(T x)
{
return x*x*PI;
}
double Circle_Square(long x)
{
return x*x*PI;
}
void main()
{
int r1=1;
double r2=2.0;
long r3=3;
cout<<"The first cs is "<<CS(r1)<<endl;
swap(x,y);
cout<<"after swap, x:"<<x<<" ,y:"<<y;
}
void swap(int &rx,int &ry)
{
int t=rx;
rx=ry;
ry=t;
}
#include<iostream>
//using namespace std;
void main()
/*{
using namespace std;
inline double circumference(double radius);
void main()
{
double r=3.0,s;
s=circumference(r);
cout<<"the circumference is "<<s<<"."<<endl;
void main()
{
int typeA=0,typeB=0;
int student=6;
int gradesize=4;
for(int i=0;i<student;i++)
level(array[i],gradesize,typeA,typeB)++;
cout<<"number of type A is "<<typeA<<endl;
}
inline double circumference(double radius)
{
return 2*3.1415926*radius;
}
/* Note:Your choice is C IDE */
#include <iostream.h>
int add(int x,int y)
{
int sum;
#include <iostream.h>
void main()
{
int num;
int &ref=num;
num=5;
cout<<"num="<<num<<endl;
cout<<"ref="<<ref<<endl;
cout<<"&num="<<&num<<endl;
cout<<"&ref="<<&ref<<endl;
std::cout<<"please input radius: ";
std::cin>>radius;
std::cout<<"The result is "<<radius*radius*3.14*4<<"\n";
}
/* Note:Your choice is C IDE */
#include <iostream>
cout<<"the name is "<<name<<endl;
cout<<"the age is "<<age<<endl;
}
#include "iostream"
using namespace std;
void main()
{
struct student
{
int no;
floatmath;
};
{
fn2(5.0)=12.4;
cout<<fn2(5.0)<<endl;
}
/* Note:Your choice is C IDE */
#include <iostream>
#include <string>
using namespace std;
void main()
{
string s,t;
cout<<"please input a zifuchuan:"<<endl;
}
#include "iostream"
using namespace std;
void main()
{ char name[10];
int age;
cout<<"please input your name:";
cin>>name;
cout<<"how old are you:";
cin>>age;
int n;
cout<<"please input the length of the array: ";
cin>>n;
if((p=new int[n])==0)
{
cout<<"can't allocate more memory, terminating"<<endl;
exit(1);
}
for(int i=0;i<n;i++)
using namespace std;
int array[6][4]={{60,80,90,75},{75,85,65,77},{80,88,90,98},{89,100,78,81},{62,68,69,75},{85,85,77,91}};
int &level(int grade[],int size,int &tA,int &tB );
double radius;
cout<<"please input radius:";
cin>>radius;
double result=radius*radius*3.14*4;
相关主题