当前位置:网站首页>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;
}
}
}边栏推荐
- Arthas watch grabs a field / attribute of the input parameter
- What's wrong with SD card data damage? How to recover SD card data damage
- Kingbasees plug-in KDB of Jincang database_ database_ link
- Ffmpeg mix
- Why should programmers learn microservice architecture if they want to enter a large factory?
- GFS分布式文件系统(光是遇见已经很美好了)
- [set theory] binary relationship (binary relationship notation | binary relationship from a to B | number of binary relationships | example of binary relationship)
- SSM based campus part-time platform for College Students
- Two drawing interfaces - 1 Matlab style interface
- [set theory] set concept and relationship (set represents | number set | set relationship | contains | equality | set relationship property)
猜你喜欢

BMZCTF simple_ pop

一名外包仔的2022年中总结

FISCO bcos zero knowledge proof Fiat Shamir instance source code

Busycal latest Chinese version
![[literature reading] sparse in deep learning: practicing and growth for effective information and training in NN](/img/7e/50fa6f65b5a4f0bb60909f57daff56.png)
[literature reading] sparse in deep learning: practicing and growth for effective information and training in NN

The time has come for the domestic PC system to complete the closed loop and replace the American software and hardware system

X-ray normal based contour rendering
![[fxcg] inflation differences will still lead to the differentiation of monetary policies in various countries](/img/56/386f0fd6553b8b9711e14c54705ae3.jpg)
[fxcg] inflation differences will still lead to the differentiation of monetary policies in various countries

JS realizes the animation effect of text and pictures in the visual area

A outsourcing boy's mid-2022 summary
随机推荐
多板块轮动策略编写技巧----策略编写学习教材
使用BENCHMARKSQL工具对kingbasees并发测试时kill掉主进程成功后存在子线程未及时关闭
[Thesis Writing] how to write the overall design of JSP tourism network
When using the benchmarksql tool to preheat data for kingbasees, execute: select sys_ Prewarm ('ndx_oorder_2 ') error
Bugku CTF daily question baby_ flag. txt
4 years of experience to interview test development, 10 minutes to end, ask too
[no title] 2022 chlorination process examination content and free chlorination process examination questions
Square root of X
C language series - Section 3 - functions
[set theory] Cartesian product (concept of Cartesian product | examples of Cartesian product | properties of Cartesian product | non commutativity | non associativity | distribution law | ordered pair
Function introduction of member points mall system
Know that Chuangyu cloud monitoring - scanv Max update: Ecology OA unauthorized server request forgery and other two vulnerabilities can be detected
[nlp] - brief introduction to the latest work of spark neural network
2022-02-13 (347. Top k high frequency elements)
Basic MySQL operations
Competitive product analysis and writing
Solve BP Chinese garbled code
[fxcg] inflation differences will still lead to the differentiation of monetary policies in various countries
Web - Information Collection
Basic syntax of class