📄 powers.cpp
字号:
// powers.cpp A program to prepare and reference a 2-d array of integer powers// ASSUMPTIONS: the integers 0 through 9 are represented by powers 1 through 4#include <iostream.h>// A function to fill a 2-d table of 10 rows with powers 1 through 4void FillTable (int tab[][5]){ int row, col, product, n; for (row=0; row<10; row++) for (col = 0; col<5; col++) { product = 1; // each cell is the integer value times itself a `col' for (n=0; n<col; n++) // number of times product *= row; tab[row][col] = product; }}void main(){ int table[10][5], // table of integer powers intval, power; // requested integer value and power (from user) FillTable (table); cout << "Enter integer (0 to 9) and requested power (1 to 4): "; cin >> intval >> power; cout << intval << " raised to a power of " << power << " is " << table[intval][power];}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -