📄 program_6_4.cpp
字号:
// program 6.4: local scope
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main() {
cout << "5 random numbers from 0 to 99:" << endl;
srand( (unsigned int) time(0) );
for ( int i=1; i<=5; ++i ) {
cout << rand()%100 << endl;
}
// print i
cout << "scope testing: i = " << i << endl;
return 0;
}
// another example
#include <iostream>
using namespace std;
void Mystery(int a, int b); // prototype
int main() {
int i = 10;
int j = 20;
Mystery(i, j);
cout << a << endl;
cout << b << endl;
return 0;
}
void Mystery(int a, int b) {
cout << a << endl;
cout << b << endl;
a = 1;
b = 2;
cout << a << endl;
cout << b << endl;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -