题意:

输入一个字符串长度为5~80,以'U'型输出,使得底端一行字符数量不小于侧面一列,左右两列长度相等。

trick:

不把输出的数组全部赋值为空格为全部答案错误,可能不赋值数组里值为0,赋值后是' ',空格的ascii是32,初读题面时并没有看到要输出空格,因为打印0其实效果看起来好像一样。。。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
string s;
char a[][];
int main(){
memset(a,' ',sizeof(a));
cin>>s;
int n=s.size();
int x=(n+)/;
for(int i=;i<=x;++i)
a[i][]=s[i-];
for(int i=x+;i<=n-x;++i)
a[x][i-x+]=s[i-];
for(int i=x;i>=;--i)
a[i][n-*x+]=s[n-i];
for(int i=;i<=x;++i){
for(int j=;j<=n-*x+;++j)
cout<<a[i][j];
if(i!=x)
cout<<"\n";
}
return ;
}

【PAT甲级】1031 Hello World for U (20 分)的更多相关文章

  1. PAT 甲级 1031 Hello World for U (20 分)(一开始没看懂题意)

    1031 Hello World for U (20 分)   Given any string of N (≥) characters, you are asked to form the char ...

  2. PAT甲级:1136 A Delayed Palindrome (20分)

    PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...

  3. PAT 甲级 1054 The Dominant Color (20 分)

    1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...

  4. PAT 甲级 1027 Colors in Mars (20 分)

    1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...

  5. PAT 甲级 1005 Spell It Right (20 分)

    1005 Spell It Right (20 分) Given a non-negative integer N, your task is to compute the sum of all th ...

  6. PAT 甲级 1058 A+B in Hogwarts (20 分) (简单题)

    1058 A+B in Hogwarts (20 分)   If you are a fan of Harry Potter, you would know the world of magic ha ...

  7. PAT 甲级 1023 Have Fun with Numbers (20 分)(permutation是全排列题目没读懂)

    1023 Have Fun with Numbers (20 分)   Notice that the number 123456789 is a 9-digit number consisting ...

  8. PAT Advanced 1031 Hello World for U (20 分)

    Given any string of N (≥) characters, you are asked to form the characters into the shape of U. For ...

  9. 【PAT甲级】1054 The Dominant Color (20 分)

    题意: 输入两个正整数M和N(M<=800,N<=600),分别代表一张图片的宽度和高度,接着输入N行每行包括M个点的颜色编号,输出这张图片主导色的编号.(一张图片的主导色占据了一半以上的 ...

  10. 【PAT甲级】1001 A+B Format (20 分)

    题意:给两个整数a,b,计算a+b的值并每三位用逗号隔开输出(−1e6​​≤a,b≤1e6​​) AAAAAccepted code: #include<bits/stdc++.h> us ...

随机推荐

  1. Mysql2docx自动生成数据库说明文档

    [需要python3.0以上] 首先安装Mysql2docx,如下: pip install Mysql2docx 然后打开pycharm,新建test.py # python from Mysql2 ...

  2. nginx反向代理配置及常见指令

    nginx配置文件: /usr/local/nginx1.16.1/conf/nginx.conf nginx.conf默认的server配置: server{ listen 80; server_n ...

  3. eclipse链接mySQL数据库常见错误

    1错误: 解决: 2,用户名输入错误 解决:查看自己的正确用户名https://zhidao.baidu.com/question/248308313.html 3. 解决: 链接示例:https:/ ...

  4. Jmeter_接口串联自动化测试_登录后充值获取cookie

    1.登陆->充值->运行会报错 2,那如何解决这个问题呢,添加HTTP COokie管理器 另外一种方法,登录->提取正则表达式,充值->添加HTTP cookie管理器

  5. css 中 max-width 和 min-width 的区别

    max-width:规定元素本身最大宽度,即元素本身 (该div) 的宽度应小于等于其最大宽度值. min-width:规定元素本身最小宽度,即元素本身应大于等于其宽度值. 例:min-width:1 ...

  6. Javascript中forEach的异步问题

    某天尝试了下在 forEach函数中调用 await Promise() 方法,如下: var arr = [1,2,3] arr.forEach(async (v,i,a)=>{ await ...

  7. RabbitMQ连接池、生产者、消费者实例

    1.本文分享RabbitMQ的工具类,经过实际项目长期测试,在此分享给发家,各位大神有什么建议请指正 !!! 2.下面是链接池主要代码: import java.util.HashMap; impor ...

  8. 开放应用模型操作指南(一)| 云服务一键接入 OAM 体系

    作者 | 邓洪超  阿里云容器平台软件工程师 导读:Open Application Model(OAM)是阿里云联合微软等国际顶级技术团队联合发布的开放应用模型技术.旨在通过全新的应用定义.运维.分 ...

  9. WinForm开发(3)——使用vs2017打包winform安装程序的过程

    一.安装打包插件 注:安装好重启vs2017 ​ ​ 二.打包过程 ​ ​ 添加文件入口 ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

  10. 18 JavaScript字符串方法

    indexOf():从头到尾进行检索.返回指定文本在字符串最后一次出现的索引,否则返回-1.可以指定第二个参数作为起始位置. lastIndexOf:从尾到头进行检索.返回指定文本最后出现的位置,否则 ...