赞
踩
题目链接
我们都学过九九乘法表,现在我们将它扩展成12*12的乘法表,请你输出这个乘法表的前N行。
Input
输入一个数N,其中1≤N≤12
Output
输出一个乘法表,每行几个算式之间以空格隔开
5
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
1*4=4 2*4=8 3*4=12 4*4=16
1*5=5 2*5=10 3*5=15 4*5=20 5*5=25
输入一个数n,输出n行的乘法表。提示:用两重for循环实现。
C++代码:
#include<bits/stdc++.h> using namespace std; int main() { int n; while(cin >> n) { for(int i = 1; i <= n; i++) { for(int j = 1; j <= i; j++) cout << j << "*" << i << "=" << j * i << " "; cout << endl; } } return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。