#include <iostream.h>vodi myFunction();int a=1,b=2;main(){cout<<" Function main:a="<<a<<"\n";cout<<" Function main:b="<<b<<"\n";cout<<" Function main:a+b="<<a+b<<"\n";myFunction();}void myFunction(){int c=3;cout<<" Function myFunction:a="<<a<<"\n";cout<<" Function myFunction:b="<<b<<"\n";cout<<" Function myFunction:c="<<c<<"\n";cout<<" Function myFunction:a+b-c="<<a+b-c<<"\n";}
2 回答
森林海
TA贡献2011条经验 获得超2个赞
出错原因:代码写的太少了,多练习。C语言的习惯影响了你。熟能生巧,呵呵。新手吧
==========================正确代码=====================================
#include <iostream.h>
void myFunction();
int a=1,b=2;
main()
{
cout<<" Function main:a="<<a<<endl;
cout<<" Function main:b="<<b<<endl;
cout<<" Function main:a+b="<<a+b<<endl;
myFunction();
}
void myFunction()
{
int c=3;
cout<<" Function myFunction:a="<<a<<endl;
cout<<" Function myFunction:b="<<b<<endl;
cout<<" Function myFunction:c="<<c<<endl;
cout<<" Function myFunction:a+b-c="<<a+b-c<<endl;
}
- 2 回答
- 0 关注
- 261 浏览
添加回答
举报
0/150
提交
取消