【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 ...
随机推荐
- GBK与Unicode的转换
一.GBK转换到Unicode编码 std::string Gbk2Unicode(std::string &strValue) { std::string strReturn; unsign ...
- LoadRunner通过火狐浏览器录制脚本后,进行回放时,回放脚本很慢
原因:火狐浏览器在录制的时候,录制了下载插件的脚本 解决办法:在脚本中删除额外资源中的下载代码
- Python短文本自动识别个体是否有自杀倾向【新手必学】
我们以微博树洞为例,讲解了怎么自动爬取单个微博的评论.今天我们就要用上这些数据做一个自杀倾向分类器,这样的分类器如果应用得当,将可以帮助成千上万误入歧途的人们挽回生命. 为了简化问题,我们将短文本分为 ...
- oracle 12cR2 RAC deconfig CRS过程记录
已经停了该节点的crs所有服务: [root@jhjzksrv02 install]# ./rootcrs.sh -force -deconfig -verboseUsing configuratio ...
- 两个Beta函数类型的积分及其一般形式
\[\Large\displaystyle \int_{0}^{1}\frac{\sqrt[4]{x\left ( 1-x \right )^{3}}}{\left ( 1+x \right )^{3 ...
- 巨头环伺下,青云QingCloud的云计算之路危机重重
编辑 | 于斌 出品 | 于见(mpyujian) 随着互联网.科技行业的深入发展,国内云计算市场正越来越爆发出惊人的潜力,大量大.中.小型玩家开始不断发力,涌现出了一大批增速明显的行业玩家. 以BA ...
- linux查看端口占用程序
netstat -apn 查看所有进程和端口的使用情况,看到9000端口和28080端口被java程序占用,PID分别为17607,1442 ps -aux|grep 17607 ps -aux|g ...
- $ git push -u origin master
我们第一次推送master分支时,由于远程库是空的,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来 ...
- 【Go语言系列】1.4、GO语言简介:第一个Go语言程序
接下来我们来编写第一个 Go 程序 hello.go(Go 语言源文件的扩展是 .go),代码如下: // 声明 main 包 package main import ( "fmt" ...
- rsync安装与配置使用 数据同步方案(centos6.5)
rsync + crond ==定时数据同步 sersync(inotify) + rsync ==实时数据同步,利用rsync实现 ##应用场景 ..1 主备服务器之间同步数据定时 = ...