【PAT甲级】1031 Hello World for U (20 分)
题意:
输入一个字符串长度为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 分)的更多相关文章
- 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 ...
- PAT甲级:1136 A Delayed Palindrome (20分)
PAT甲级:1136 A Delayed Palindrome (20分) 题干 Look-and-say sequence is a sequence of integers as the foll ...
- PAT 甲级 1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 【PAT甲级】1054 The Dominant Color (20 分)
题意: 输入两个正整数M和N(M<=800,N<=600),分别代表一张图片的宽度和高度,接着输入N行每行包括M个点的颜色编号,输出这张图片主导色的编号.(一张图片的主导色占据了一半以上的 ...
- 【PAT甲级】1001 A+B Format (20 分)
题意:给两个整数a,b,计算a+b的值并每三位用逗号隔开输出(−1e6≤a,b≤1e6) AAAAAccepted code: #include<bits/stdc++.h> us ...
随机推荐
- md5模块(Python内置模块)和hashlib模块
转自https://my.oschina.net/duhaizhang/blog/67214 MD5模块用于产生消息摘要,康用来判断文件是否相同. python的md5模块使用非常简单,包括以下几个函 ...
- winform BackgroundWorker 的用法 - 异步执行
1.设置 backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.WorkerSupportsCancellation = ...
- 在elementui表单中实现对vue-quill-editor富文本编辑器内容的绑定
1.v-model(表单标签双向绑定指令) v-model相当于:value=""和@input=""的结合 代码1: <input type=" ...
- EntityFramework 插入自增ID主从表数据
原因: 数据库中的两个表是主从表关系,但是没有建外键,而表的id用的是数据库的自增整数,导致在使用EF导入主从表数据时,需要先保存主表数据,取到 主表的自增id后才能插入从表数据,这样循环之下,数据插 ...
- Django - 在settings配置终端打印SQL语句
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'level': 'DE ...
- 负环--spfa
洛谷板子题 负环?是有负权边的环还是一个边权之和为负的环? 还没有准确的定义(那就先忽略吧qwq 判断负环的方法: 暴力枚举/spfa/mellman—ford/奇怪的贪心/超神的搜索 可惜我只会sp ...
- es6二进制数组--基础
一.概念二进制数组由 ArrayBuffer对象 TypeArray 视图和DataView视图 三部分组成是javascript操作二进制数据的一个接口. 早在2011年2月就已经发布,但是由于ES ...
- 【代码学习】PYTHON 生成器
一.生成器 一遍循环一遍计算的机制,称为生成器 二.生成器的特点: 1.节约内存 2.迭代到下一次的调用时,所使用的参数都是第一次所保留下的,即是说,在整个所有函数调用的参数都是第一次所调用时保留的, ...
- windows 10安装linux(ubuntu)子系统
windows10安装ubuntu子系统系统 之前一直在虚拟机中使用linux系统,但是不是很方便,后来发现windows下也有了linux系统.感觉还不错 1. 打开windows应用市场micro ...
- vue 实现简单的富文本编辑
安装:npm install vue-quill-editor --save 安装Vue-Quill-Editor需要依赖: npm install quill --save 在入口文件main.js ...