题意:

输入一个字符串长度为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. php 加解密函数

    PHP 加密解密函数: /** * 系统加密方法 * @param string $data 要加密的字符串 * @param string $key 加密密钥 * @param int $expir ...

  2. Python实现重命名一个文件夹下的图片

    在网上查了一下python实现的图片重命名,工作中刚好用一下. # -*- coding:utf8 -*- import os path = '新建文件夹 (2)/' filelist = os.li ...

  3. 20-02-27 hive表的几个问题

    1.hive表的动态分区 2.hive  表如何修改列名 3.group  by  对统计指标的影响  (group by 的本质) 4.row_number 对数据的影响

  4. 【CSS属性#2】

    " 目录 一.盒子模型 二.外边距 margin 三.内填充 padding 四.浮动 float 五.清除浮动 clear 六.溢出 overflow 七.定位 position 1. 无 ...

  5. 【笔记4-商品模块】从0开始 独立完成企业级Java电商网站开发(服务端)

    分类管理模块 数据表结构设计 分类表 CREATE TABLE.mmall_ category' ( 'id' int(11) NOT NULL AUTO_ INCREMENT COMMENT ' 类 ...

  6. spark实验(二)--eclipse安装scala环境(2)

    此次在eclipse中的安装参考这篇博客https://blog.csdn.net/lzxlfly/article/details/80728772 Help->Eclipse Marketpl ...

  7. AOP的基本认识

    一.AOP的概念 AOP(Aspect Oriented Programming),即面向切面编程,可以说是OOP(Object Oriented Programming,面向对象编程)的补充和完善. ...

  8. MySQL 将字符串转换为数字

    转载自:https://www.cnblogs.com/xiaoleiel/p/8316508.html 在操作mysql时,经常需要将字符转换成数字,这一步虽然简单,但不常用的话也很容易忘记,现将在 ...

  9. DOC文档与DOCX文档有什么区别

    doc 是 Microsoft Office 2003 里的 Word 文档,而 docx 是 Microsoft Office 2007 里的 Word 文档.高版本是向下兼容的,也就是能够打开 d ...

  10. ARG 构建参数----Dockerfle文件的重用

    ARG 构建参数----Dockerfle文件的重用 格式:ARG <参数名>[=<默认值>] 构建参数和 ENV 的效果一样,都是设置环境变量. 所不同的是,ARG 所设置的 ...