当前位置:网站首页>1031 Hello world for u (20 points)
1031 Hello world for u (20 points)
2022-06-30 14:55:00 【Xue Dongjing】
1031 Hello World for U (20 branch )
The question
Give a string length n(5<=n<=80), Press this string U Glyph output .
The output is divided into three parts , The first part is long n1,U The left side of the , The second part is long n2,U The bottom of , The third part n3,U The right part of .
n1=n3<=n2, And n1 And n2 The difference should be as small as possible .n1+n2+n3-2=n.
Ideas
Handle the position of each character . front (n1-1) Line output U On both sides of , The number of spaces in the middle is n2, Change the space in the middle of the last line to the letter at the bottom of the output . Notice that the last letter of the first and third parts is at the bottom .
Code
#include<stdio.h>
#include<string.h>
char str[300];
void print1(int n2)
{
for(int i=0;i<n2;i++){
printf(" ");
}
}
void print(int n1,int n2,int sum)
{
for(int i=0;i<n1;i++){
if(i!=0){
printf("\n");
}
printf("%c",str[i]);
if(i<n1-1){
print1(n2);
}else{
for(int j=0;j<n2;j++){
printf("%c",str[n1+j]);
}
}
printf("%c",str[sum-1-i]);
}
}
int main()
{
int sum, n1, n2;
scanf("%s",str);
sum=strlen(str);
n1=(sum+2)/3;
n2=sum-n1*2;
print(n1,n2,sum);
return 0;
}
边栏推荐
- Uniapp upload image method
- Querywrapper in mybaits plus
- 1136: password translation
- 1130: find the first character that appears only once
- Examples of bubble sorting and matrix element screening in MATLAB
- Basic requirements for tool use in NC machining of vertical machining center
- Lost connection to the flow server (0 retries remaining): |Out of retries, exiting! Error reporting solution (flow)
- Is it troublesome for CITIC futures to open an account? Is it safe? How much is the handling charge for opening an account for futures? Can you offer a discount
- Add attributes to multimode
- Matlab two-dimensional array example (extract data)
猜你喜欢

ThinkPHP v3.2 comment annotation injection write shell

How to realize selective screen recording for EV screen recording

Sum of CCF digits (full mark code + problem solving idea) 201512-1

Lihongyi machine learning 2020 homework summary

JS to realize simple lottery function

CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015

Matlab construction operation example

CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1

V3 03_ Getting started

ctfshow nodejs
随机推荐
Learn about data kinship JSON format design from sqlflow JSON format
How many questions can you answer for the interview of Mechanical Engineer?
1 figure to explain the difference and connection between nodejs and JS
Programming exercises: whole point and circle (solution ideas and code implementation)
Summary of C language interview questions
Is it troublesome for CITIC futures to open an account? Is it safe? How much is the handling charge for opening an account for futures? Can you offer a discount
CCF Z-scan (full mark code + problem solving ideas) 201412-2
val_ Loss decreases first and then increases or does not decrease but only increases
V3 03_ Getting started
jsPlumb. Deleteeveryconnection is not a function & jsplumb clear canvas jsplumb delete all nodes and all connections
CCF adjacent number pairs (Full Score code + problem solving ideas + skill summary) 201409-1
Sum of squares of two pointers
ctfshow nodejs
Knowledge learned from the water resources institute project
[extensive reading of papers] a delicious recipe analysis framework for exploring multi modal recipes with variable attributes
1134: Legal C identifier query
Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)
JS array sorting method summary
In situ merging of two arrays with two pointers
How to program and process such parts?