题目描述
输入一个整数 N,输出 N 的乘法表,如下:
1 x N = N
2 x N = 2N
…
10 x N = 10N
输入格式
一个整数 N。
输出格式
输出 N 的乘法表,具体形式参照输出样例。
数据范围
1<N<1000
样例
输入样例:
140
输出样例:
1 x 140 = 140
2 x 140 = 280
3 x 140 = 420
4 x 140 = 560
5 x 140 = 700
6 x 140 = 840
7 x 140 = 980
8 x 140 = 1120
9 x 140 = 1260
10 x 140 = 1400
算法1
一个一个老老实实地写(不建议用)
C++ 代码
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
scanf("%d",&n);
cout<<"1 x "<<n<<" = "<<n<<endl;
cout<<"2 x "<<n<<" = "<<2*n<<endl;
cout<<"3 x "<<n<<" = "<<3*n<<endl;
cout<<"4 x "<<n<<" = "<<4*n<<endl;
cout<<"5 x "<<n<<" = "<<5*n<<endl;
cout<<"6 x "<<n<<" = "<<6*n<<endl;
cout<<"7 x "<<n<<" = "<<7*n<<endl;
cout<<"8 x "<<n<<" = "<<8*n<<endl;
cout<<"9 x "<<n<<" = "<<9*n<<endl;
cout<<"10 x "<<n<<" = "<<10*n<<endl;
return 0;
}
算法2
用for循环
C++ 代码
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
scanf("%d",&n);
for(int i=1; i<=10; i++)
{
cout<<i<<" x "<<n<<" = "<<i*n<<endl;
}
return 0;
}