数组做为函数参数

 

#include "iostream.h"
char shuzu(int n)
{
return (char)(n);
}
void main()
{ int a[5]={110,98,109,102,100},i;
for (i=0;i<=4;i++)
{cout<<a[i]<<":"<<shuzu(a[i])<<endl;}
}

在主函数中定义一个数组,并给它初始化,用一个循环调用子函数,通过子函数返值,子函数的功能:将主函数传过去的值转换为ASCII的值,在返回主函数在输出!!!1

原文地址:https://www.cnblogs.com/qiqiBoKe/p/2791606.html