?? ch03.03.c
字號:
// typically this is placed within a separate
// program text file, such as pow.c
// and precompiled into a library ...
// programs wishing to invoke it,
// link in the library
int pow( int val, int exp )
{
for ( int res = 1; exp > 0; --exp )
res = res * val;
return res;
}
// #include <iostream>
#include <iostream.h>
// necessary if the executable is not included
// within this program text file ...
extern int pow(int,int);
/*****
The Powers of 2
0: 1
1: 2
2: 4
3: 8
4: 16
5: 32
6: 64
7: 128
8: 256
9: 512
10: 1024
11: 2048
12: 4096
13: 8192
14: 16384
15: 32768
*****/
int main()
{
int val = 2;
int exp = 15;
cout << "The Powers of 2\n";
for ( int cnt=0; cnt <= exp; ++cnt )
cout << cnt << ": "
<< pow( val, cnt ) << endl;
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -