c++中的乘法规则有人能写下代码给我看?

来源:百度知道 编辑:UC知道 时间:2024/05/21 11:32:10
1x1=1 1x2=2....1x9=9
2x1=2......2x9=18
3x1=3...3x9=27
.
.
.
9x1=9...9x9=81

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
for(int row = 1; row <= 9; ++row)
{
for(int col = row; col <= 9; ++col)
cout << col << "×" << row << "=" << setw(2) << col * row << setw(3) << ' ';
cout << endl;
}
}

照你说的打成矩形了,而且有重复,比如1×2和2×1,
如果那是你需要的,那么稍微改下就可以了:

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
for(int row = 1; row <= 9; ++row)
{
for(int col = 1; col <= 9; ++col)
cout << col << "×" << row << "=" << setw(2) << col * row << setw(3) << ' ';
cout << endl;
}
}

#include<iostream.h>
void main(){
int a,b,i;
for(a=1;a<10;a++)
{
f