20 条题解
-
21
暴 力 极 了
#include <iostream>//hetao3097453 using namespace std; int main() { int n; cin >> n; if(n == 1) { cout << "1*1=1"; } else if(n == 2) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; } else if(n == 3) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; } else if(n == 4) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; } else if(n == 5) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; } else if(n == 6) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36" << endl; } else if(n == 7) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36" << endl; cout << "7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49" << endl; } else if(n == 8) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36" << endl; cout << "7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49" << endl; cout << "8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64" << endl; } else if(n == 9) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36" << endl; cout << "7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49" << endl; cout << "8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64" << endl; cout << "9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81" << endl; } return 0; }
-
4
暴 力 极 了,但是优化版
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; if (n >= 1)//此处可省略 cout << "1*1=1\n"; if (n >= 2) cout << "2*1=2 2*2=4\n"; if (n >= 3) cout << "3*1=3 3*2=6 3*3=9\n"; if (n >= 4) cout << "4*1=4 4*2=8 4*3=12 4*4=16\n"; if (n >= 5) cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25\n"; if (n >= 6) cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36\n"; if (n >= 7) cout << "7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49\n"; if (n >= 8) cout << "8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64\n"; if (n >= 9) cout << "9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81\n"; return 0; }
-
3
此题很简单,
但很多人不会可以暴力破解(详见[潘广璨 (hetao3097453) ]、[FYCCCTA (hetao1411188)]的题解)AC代码走起!#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { cout << i << "*" << j << "=" << i * j << " "; } cout << endl; } return 0; }
请注意必须抄袭题解,写题解需要只放代码,不需加上你的思路或代码注释。抄袭题解一经发现直接成绩满分!!!
-
2
《作业
答案表》#include<iostream> using namespace std; int main(){ int n; n = 134; for(int i = 1;i <= n;i++){ cout << i << ": "; for(int j = 1;j <= i;j++){ cout << i << "*" << j << "=" << i * j << " "; } cout << endl << endl; } return 0; }
不搞事情,上代码
#include <iostream> using namespace std; int main() { int n; cin >> n; if(n == 1) { cout << "1*1=1"; } else if(n == 2) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; } else if(n == 3) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; } else if(n == 4) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; } else if(n == 5) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; } else if(n == 6) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36" << endl; } else if(n == 7) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36" << endl; cout << "7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49" << endl; } else if(n == 8) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36" << endl; cout << "7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49" << endl; cout << "8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64" << endl; } else if(n == 9) { cout << "1*1=1" << endl; cout << "2*1=2 2*2=4" << endl; cout << "3*1=3 3*2=6 3*3=9" << endl; cout << "4*1=4 4*2=8 4*3=12 4*4=16" << endl; cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25" << endl; cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36" << endl; cout << "7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49" << endl; cout << "8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64" << endl; cout << "9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81" << endl; } return 0; }
搞错了,再来
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; if (n >= 1) cout << "1*1=1\n"; if (n >= 2) cout << "2*1=2 2*2=4\n"; if (n >= 3) cout << "3*1=3 3*2=6 3*3=9\n"; if (n >= 4) cout << "4*1=4 4*2=8 4*3=12 4*4=16\n"; if (n >= 5) cout << "5*1=5 5*2=10 5*3=15 5*4=20 5*5=25\n"; if (n >= 6) cout << "6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36\n"; if (n >= 7) cout << "7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49\n"; if (n >= 8) cout << "8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64\n"; if (n >= 9) cout << "9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81\n"; return 0; }
#include<iostream> using namespace std; int main(){ int n; cin >> n; for(int i = 1;i <= n;i++){ for(int j = 1;j <= i;j++){ cout << i << "*" << j << "=" << i * j << " "; } cout << endl; } return 0; }
-
0
此题很简单!
我们来列表梳理
如果i为行数,j为列数(表格里为结束位置); n为5;
第一行 第二行 第三行 第四行 第五行 i=1 i=2 i=3 i=4 i=5 j=1 j=2 j=3 j=4 j=5
分析完毕后我们发现结束的j会等于i(行数) 内层循环那就出来了
for(int j=1;j<=i;j++) { cout<<i<<"*"<<j<<"="<<i*j<<" "; } cout<<endl;
至于外层的结束条件你们肯定知道!
我就不上代码了#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { cout<<i<<"*"<<j<<"="<<i*j<<" "; } cout<<endl; } return 0; }
记得点赞❤️
- 1
信息
- ID
- 246
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 2
- 标签
- 递交数
- 1076
- 已通过
- 678
- 上传者