C程序设计编程实例大全

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
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;
}
void main()
{
int a[]={1,3,0,2,7,6,4,5,2};
double b[]={1.2,-3.4,6.8,9.8};
int c[]={1,9,5,-6,7,8};
cout<<"a de shuzu zhong min zhi wei:"<<min(a,9)<<endl;
cout<<"b de shuzu zhong min zhi wei:"<<min(b,4)<<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;
int n;
cin>>n;
student wang;
wang.no=n;
cin>>wang.math;
cout<<wang.no<<" "<<wang.math<<endl;
}
#include "iostream"
using namespace std;
void main()
{
int *p;
int n;
int year;
}
#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;
p[i]=i*i+1;
cout<<"Now output the array: "<<endl;
for(i=0;i<n;i++)
cout<<p[i]<<" ";
cout<<endl;
delete []p;
}
/* Note:Your choice is C IDE */
#include <iostream>
int &ref=num;
ref+=10;
cout<<"num="<<num<<endl;
cout<<"ref="<<ref<<endl;
num+=40;
cout<<"num="<<num<<endl;
cout<<"ref"<<ref<<endl;
}
/* Note:Your choice is C IDE */
cout<<"The third cs is "<<CS(r3)<<endl;
}
/* Note:Your choice is C IDE */
#include <iostream.h>
void main()
{
int i=0,&l=i,&k=l;
i=++l-k;
cout<<"i="<<i<<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>
using namespace std;
inline double circumference(double radius);
void main()
{
double r=3.0,s;
s=circumference(r);
cout<<"the circumference is "<<s<<"."<<endl;
cout<<"the name is "<<name<<endl;
cout<<"the age is "<<age<<endl;
}
#include "iostream"
using namespace std;
void main()
{
struct student
{
int no;
floatmath;
};
using namespace std;
float a=2.4;
void main()
{
int a=8;
cout<<a<<endl;
cout<<::a<<endl;
}
/* Note:Your choice is C IDE */
#include <iostream.h>
void main()
{
int num=50;
C++程序编程实例大全
#include<iostream>
int main()
{
std::cout<<"hello world!";
}
#include "iostream"
using namespace std;
void main()
{
int *p;
p=new int;
*p=5;
/*p=new int(5);*/
p[i]=i*2;
cout<<"Now output the array: "<<endl;
for(i=0;i<n;i++)
cout<<p[i]<<" "<<endl;
delete []p;
}
#include "iostream"
using namespace std;
void main()
{
int *p;
#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;
cout<<"c de shuzu zhong min zhi wei:"<<min(c,6)<<endl;
}
/* Note:Your choice is C IDE */
#include <iostream.h>
#define CS Circle_Square
template<class T>
double Circle_Square(T x)
}
/* 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;
}
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;
{
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;
cout<<"The second cs is "<<CS(r2)<<endl;
double radius;
cout<<"please input radius:";
cin>>radius;
double result=radius*radius*3.14*4;
cout<<"The result is "<<(double)result<<"\n";
}
*/
{
double radius;
cout<<*p;
delete p;
}
#include "iostream"
using namespace std;
void main()
{ char name[10];
cout<<"please input your name:";
cin>>name;
cout<<"the name is "<<name<<endl;
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++)
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>
return tA;
else
return tB;
}
/* Note:Your choice is C IDE */
#include <iostream>
using namespace std;
float &fn2(float r)
{
float t;
t=3.14*r*r;
return t;
}
void main()
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 );
}
/* Note:Your choice is C IDE */
#include <iostream.h>
class Tdate
{
public:
void set(int,int,int);
int isLeapYear();
void print();
private:
int month;
int day;
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++)
swap(x,y);
cout<<"after swap, x:"<<x<<" ,y:"<<y;
}
void swap(int &rx,int &ry)
相关文档
最新文档