#include"iostream"
using namespace std;
int main()
{
void sort(int *p,int n);
int a[5],i;
cout<<"input array:"<<endl;
for(i=0;i<5;i++)
cin>>a[i];
cout<<endl;
sort(a,5);
cout<<" the sorted array:"<<endl;
for(i=0;i<5;i++)
cout<<a[i]<<" ";
cout<<endl;
return 0;
}
void sort(int *p,int n)
{
int i,j,k,temp;
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(*(p+j)<*(p+k)) k=j;
temp=*(p+k);
*(p+k)=*(p+i);
*(p+i)=temp;
}
}
| 实参 | 形参 |
| 数组名 | 数组名 |
| 数组名 | 指针变量 |
| 指针变量 | 数组名 |
| 指针变量 | 指针变量 |
//test_3 指针存放字符串
#include<iostream>
using namespace std;
// #include<string> //字符串变量
int main()
{
char str1[]="I Love C++",str2[20],*p1,*p2;
p1=str1;
p2=str2;
for(;*p1!='\0';p1++,p2++)
*p2=*p1;
*p2='\0';
p1=str1;
p2=str2;
cout<<"str1 is "<<p1<<endl;
cout<<"str2 is "<<p2<<endl;
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int max(int x, int y);
int (*p)(int,int);
int a,b,m;
p=max;
cin>>a>>b;
m=p(a,b);
cout<<"max is "<< m<<endl;
return 0;
}
int max(int x,int y)
{
int z;
if (x<y)
z=y;
else
z=x;
return(z);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有