当前位置:网站首页>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;
}
}
}边栏推荐
- Know that Chuangyu cloud monitoring - scanv Max update: Ecology OA unauthorized server request forgery and other two vulnerabilities can be detected
- Xrandr modifier la résolution et le taux de rafraîchissement
- Two points -leetcode-540 A single element in an ordered array
- Basic MySQL operations
- Ffmpeg mix
- [pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius
- What are the Bluetooth headsets with good sound quality in 2022? Inventory of four high-quality Bluetooth headsets
- MC Layer Target
- Design and implementation of JSP logistics center storage information management system
- [set theory] binary relationship (binary relationship notation | binary relationship from a to B | number of binary relationships | example of binary relationship)
猜你喜欢

JS realizes lazy loading of pictures
![[Thesis Writing] how to write the overall design of JSP tourism network](/img/02/841e8870c2ef871c182b9bb8252a83.jpg)
[Thesis Writing] how to write the overall design of JSP tourism network

2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills

Competitive product analysis and writing

FISCO bcos zero knowledge proof Fiat Shamir instance source code
![[free completion] development of course guidance platform (source code +lunwen)](/img/14/7c1c822bda050a805fa7fc25b802a4.jpg)
[free completion] development of course guidance platform (source code +lunwen)

When using the benchmarksql tool to test the concurrency of kingbasees, there are sub threads that are not closed in time after the main process is killed successfully

2022 P cylinder filling test content and P cylinder filling simulation test questions

P35-P41 fourth_ context

Pdf editing tool movavi pdfchef 2022 direct download
随机推荐
Solve BP Chinese garbled code
Function introduction of member points mall system
Integration of Android high-frequency interview questions (including reference answers)
Data Lake three swordsmen -- comparative analysis of delta, Hudi and iceberg
2022 P cylinder filling test content and P cylinder filling simulation test questions
使用BENCHMARKSQL工具对KingbaseES执行测试时报错funcs sh file not found
Two points -leetcode-540 A single element in an ordered array
商城系统搭建完成后需要设置哪些功能
Redraw and reflow
[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
2022 electrician (Advanced) examination papers and electrician (Advanced) examination skills
Internationalization and localization, dark mode and dark mode in compose
Priv-app permission异常
金仓数据库KingbaseES 插件kdb_exists_expand
P35-P41 fourth_ context
Five elements of user experience
使用BENCHMARKSQL工具对KingbaseES预热数据时执行:select sys_prewarm(‘NDX_OORDER_2 ‘)报错
PostgreSQL database high availability Patroni source code learning - etcd class
2022 registration of G2 utility boiler stoker examination and G2 utility boiler stoker reexamination examination
[set theory] set operation (Union | intersection | disjoint | relative complement | symmetric difference | absolute complement | generalized union | generalized intersection | set operation priority)