1
问题及代码:
#include <iostream>
using namespace std;
int a=3, b=5;
int max(int a, int b)
{
int c;
c=a>b? a:b;
return c;
}
int main()
{
int a=8;
cout<<max(a,b)<<endl;
return 0;
}
预计运行结果:8
实际运行结果:8
运行结果:
提出问题:
int a=8; //若无这一句,又将如何?
预计运行结果:5
实际运行结果:5
运行结果:
2
问题及代码:
#include <iostream>
using namespace std;
void cude();
int main()
{
extern int x;
x=5;
cude();
cout<<x<<endl;
return 0;
}
int x=10;
void cude()
{
x=x*x*x;
}
预计运行结果:125
实际运行结果:125
运行结果:
提出问题1:
extern int x;//去掉extern?
预计运行结果:5
实际运行结果:5
运行结果:
提出问题2:
x=5; //去掉这一句呢?
预计运行结果:1000
实际运行结果:1000
运行结果: