当前位置:网站首页>Hj35 serpentine matrix
Hj35 serpentine matrix
2022-07-03 04:29:00 【ChasnyChang】
describe
The snake matrix is made up of 1 The starting natural numbers are arranged in turn into a triangle on the matrix .
for example , When the input 5 when , The triangle that should be output is :
1 3 6 10 15
2 5 9 14
4 8 13
7 12
11
Please note that this question contains multiple sets of sample inputs .
Input description :
Enter a positive integer N(N No more than 100)
Output description :
Output one N Snake matrix of row .
Example 1
Input :
4
Copy output :
1 3 6 10 2 5 9 4 8 7
Challenge the most garbage practice in the whole network
#include<iostream>
using namespace std;
int main()
{
int n;
while (cin >> n)
{
int i = 1, j = n, shownum = 0, cnt = 0;
bool flag = true;
int coladdval = 0;
for (; i <= n; i++) //n=4 when , 4 That's ok
{
cnt = i+1; // The first number at the beginning of each line increases gradually
for (; j >= 1; j--) // Column decrement per row
{
if (flag) // The first output of each line
{
shownum = i + coladdval;
cout << shownum << " ";
flag = false;
}
else // Output of other columns per row
{
shownum += cnt;
cout << shownum << " ";
cnt++;
}
}
j = n - i; // Control the output of each column
flag = true;
coladdval += i - 1;
cout << "\n";
}
// n = 0;
}
return 0;
}Give me another beautiful
#include<iostream>
using namespace std;
int main()
{
int a;
while (cin >> a)
{
int m = 1;
int n;
for (int i = 0; i < a; i++)
{
m += i;
for (int j = i; j < a; j++)
{
int c = 1 + j;
if (j == i)
{
n = m;
cout << n << " ";
}
else {
cout << (n += c) << " ";
}
}
cout << endl;
}
}
}边栏推荐
- 金仓数据库KingbaseES 插件kdb_date_function
- Square root of X
- [NLP]—sparse neural network最新工作简述
- Ffmpeg tanscoding transcoding
- Why should programmers learn microservice architecture if they want to enter a large factory?
- Use the benchmarksql tool to perform a data prompt on kingbases. The jdbc driver cannot be found
- Kubernetes source code analysis (I)
- Function introduction of member points mall system
- FuncS sh file not found when using the benchmarksql tool to test kingbases
- Reptile exercise 03
猜你喜欢

Fcpx template: sweet memory electronic photo album photo display animation beautiful memory

Database management tool, querious direct download

Library management system based on SSM

Data Lake three swordsmen -- comparative analysis of delta, Hudi and iceberg

540. Single element in ordered array

Smart contract security audit company selection analysis and audit report resources download - domestic article
![[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius](/img/01/c118725f74e39742df021b5dbcc33b.jpg)
[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius

金仓KFS数据双向同步场景部署

GFS distributed file system (it's nice to meet it alone)

SSM based campus part-time platform for College Students
随机推荐
AWS VPC
Which code editor is easy to use? Code editing software recommendation
Smart contract security audit company selection analysis and audit report resources download - domestic article
How to use kotlin to improve productivity: kotlin tips
[untitled] 2022 safety production supervisor examination question bank and simulated safety production supervisor examination questions
Square root of X
[fairseq] error: typeerror:_ broadcast_ coalesced(): incompatible function arguments
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
Know that Chuangyu cloud monitoring - scanv Max update: Ecology OA unauthorized server request forgery and other two vulnerabilities can be detected
2022-02-12 (338. Bit count)
What functions need to be set after the mall system is built
Use the benchmarksql tool to perform a data prompt on kingbases. The jdbc driver cannot be found
[dynamic programming] subsequence problem
Xrandr modify resolution and refresh rate
MC Layer Target
[mathematical logic] predicate logic (toe normal form | toe normal form conversion method | basic equivalence of predicate logic | name changing rules | predicate logic reasoning law)
Factor stock selection scoring model
[set theory] set identities (idempotent law | exchange law | combination law | distribution rate | De Morgan law | absorption rate | zero law | identity | exclusion law | contradiction law | complemen
Introduction of pointer variables in function parameters
跨境电商多商户系统怎么选