当前位置:网站首页>1214 print diamond
1214 print diamond
2022-07-03 23:56:00 【Zhanglilong 666】
Title Description
Print out a symbol “*” A diamond pattern made up of .
Input requirements
Enter an integer n( Odd number ), Represents the number of rows in a diamond .
Output requirements
Diamond character * Express , Spaces without suffixes on each line .
sample input
5
sample output
* *** ***** *** *
#include<cstdio>
#include<math.h>
int main(){
int n,x,y,i,j,zll=0,p=1;
scanf("%d",&x);
zll=x/2;
for(i=1;i<=x/2;++i){// The first i That's ok .
for(j=1;j<=zll+1-i;j++){// The first j Column .
printf(" ");
}
for(j=1;j<=p;j++){// The first j Column .
printf("*");
}
p+=2;// Odd number , Add... Once in a cycle 2.
printf("\n");
}
for(i=1;i<=x;++i){// The first x That's ok .
printf("*");
}
printf("\n");
p-=2;
for(i=1;i<=x/2;i++){// The first i That's ok .
for(j=1;j<=i;j++){// The first j Column .
printf(" ");
}
for(j=1;j<=p;j++){// The first j Column .
printf("*");
}
p-=2;// Odd number , Cycle one subtraction 2.
printf("\n");
}
}
边栏推荐
- How about opening an account at Hengtai securities? Is it safe?
- How to quickly build high availability of service discovery
- Vscode regular match replace console log(.*)
- Selenium library 4.5.0 keyword explanation (II)
- SQL data update
- Learning methods of zynq
- China standard gas market prospect investment and development feasibility study report 2022-2028
- 网上的低佣金链接安全吗?招商证券怎么开户?
- How will the complete NFT platform work in 2022? How about its core functions and online time?
- 2022 chemical automation control instrument examination content and chemical automation control instrument simulation examination
猜你喜欢
Yyds dry goods inventory three JS source code interpretation - getobjectbyproperty method
[MySQL] classification of multi table queries
Solve the problem that the kaggle account registration does not display the verification code
Unity shader visualizer shader graph
Similarities and differences of text similarity between Jaccard and cosine
Docking Alipay process [pay in person, QR code Payment]
Idea a method for starting multiple instances of a service
Schematic diagram of crystal oscillator clock and PCB Design Guide
Briefly understand the operation mode of developing NFT platform
SPI based on firmware library
随机推荐
Amway by head has this project management tool to improve productivity in a straight line
Current detection circuit - including op amp current scheme
C # basic knowledge (3)
The interviewer's biggest lie to deceive you, bypassing three years of less struggle
D23:multiple of 3 or 5 (multiple of 3 or 5, translation + solution)
Pytorch learning notes 5: model creation
[MySQL] sql99 syntax to realize multi table query
Gossip about redis source code 80
[note] IPC traditional interprocess communication and binder interprocess communication principle
It is forbidden to splice SQL in code
Actual combat | use composite material 3 in application
AI Challenger 2018 text mining competition related solutions and code summary
Subgraph isomorphism -subgraph isomorphism
Collation of the most complete Chinese naturallanguageprocessing data sets, platforms and tools
Recursive least square adjustment
Ningde times and BYD have refuted rumors one after another. Why does someone always want to harm domestic brands?
[MySQL] classification of multi table queries
Solve the problem that the kaggle account registration does not display the verification code
Alibaba cloud container service differentiation SLO hybrid technology practice
NLP pre training technology development