‘,’之后要留空格,如 Function(x, y, z)

时间:2023-03-09 15:58:29
‘,’之后要留空格,如 Function(x, y, z)

‘,’之后要留空格,如 Function(x, y, z)。如果‘;’不是一行的结束 符号,其后要留空格,如 for (initialization; condition; update)。

 #include <iostream>

 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
//声明全局变量并初始化
extern int a[]={,,};
extern float p=3.14; //在show()函数中使用外部变量
show() {
int i;
cout<<"In show():"<<endl;
cout<<"p="<<p<<endl;
cout<<"a[]: ";
for (i=;i<=;i++)
cout<<a[i]<<" ";
cout<<endl;
//cout<<"y="<<y<<endl; 编译出错!
} //声明外部变量并初始化
int y=; int main(int argc, char** argv) { //声明局部变量
int i,p=; //显示重名变量
cout<<"In main():"<<endl;
cout<<"p="<<p<<endl; //显示全局变量
cout<<"::p="<<::p<<endl;
cout<<"a[]: ";
for (i=;i<=;i++)
cout<<a[i]<<" ";
cout<<endl;
cout<<"y="<<y<<endl; //编译正确! show(); //调用函数
return ;
}