当前位置:网站首页>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;
}
边栏推荐
- 浅析卧式加工中心上不规则台阶孔存在问题
- After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs
- 机械工程师面试的几个问题,你能答上来几个?
- Ctfshow getting started with the web (ThinkPHP topic)
- Add attributes to multimode
- 立式加工中心的数控加工对刀具使用基本要求
- 分布式--OpenResty+lua+Redis
- Quick sort (C language)
- Win10 one click Reset win10 to solve all system bugs without deleting any files and Applications
- Matlab to find prime pairs within 100
猜你喜欢

DefCamp Capture the Flag (D-CTF) 2021-22 web
![【BUUCTF】[GXYCTF2019]Ping Ping Ping1](/img/dc/4d87dfb0c2fa9cd75b54e092fd3971.jpg)
【BUUCTF】[GXYCTF2019]Ping Ping Ping1

How to use Alibaba Vector Icon

val_ Loss decreases first and then increases or does not decrease but only increases

2021 geek challenge Web

CCF adjacent number pairs (Full Score code + problem solving ideas + skill summary) 201409-1

Repair of incorrect deletion of win10 boot entry

Upgrade centos7 mysql5.5 to mysql5.7 non RPM in the form of tar package

The first dark spring cup dnuictf

Att & CK red team evaluation field (I)
随机推荐
Summary of C language interview questions
1134: Legal C identifier query
Using member variables and member functions of a class
CCF numerical sorting (Full Score code + problem solving ideas + skill summary) 201503-2
[extensive reading of papers] multimodal joint attribute prediction and value extraction for e-commerce product
高精度CNC加工中心为什么会出现误差?这4个原因你要注意!
这种零件该怎么编程加工?
JS delete the objects in the array and specify to delete the objects
Solution cannot use a scalar value as an array
【BUUCTF】 EasySql
文本匹配——【NAACL 2021】AugSBERT
Lfi-rce without controllable documents
Color classification of sorting
Matlab construction operation example
Clear the route cache in Vue
1137: encrypted medical record
Searching for single element in dichotomy
CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014
Greedy two-dimensional array sorting
CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1