A1031
画图,用二维数组作为画布
#include<cstdio>
#include<string.h>
int main(){
char c[],u[][];
scanf("%s",&c);
memset(u,' ',sizeof(u));
int n=strlen(c)+;
int n1=n/,n2=n/+n%,index=;
for(int i=;i<n1;i++) u[i][]=c[index++];
for(int i=;i<=n2-;i++)u[n1-][i]=c[index++];
for(int i=n1-;i>=;i--)u[i][n2-]=c[index++];
for(int i=;i<n1;i++){
for(int j=;j<n2;j++) printf("%c",u[i][j]);
printf("\n");
}
return ;
}
A1031的更多相关文章
- A1031 Hello World for U (20)(20 分)
A1031 Hello World for U (20)(20 分) Given any string of N (>=5) characters, you are asked to form ...
- A1031. Hello World for U
Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. ...
- PAT A1031 Hello World for U (20)
思路: 读取数组 int i = 0; while(cin >> word) { c[i] = word; i++; } 计算边长 int n1 = (length + 2) / 3; i ...
- PAT甲级——A1031 Hello World for U
Given any string of N (≥) characters, you are asked to form the characters into the shape of U. For ...
- PAT/图形输出习题集
B1027. 打印沙漏 (20) Description: 本题要求你写个程序把给定的符号打印成沙漏的形状.例如给定17个"*",要求按下列格式打印 ***** *** * *** ...
- 1031 Hello World for U (20 分)
1031 Hello World for U (20 分) Given any string of N (≥5) characters, you are asked to form the chara ...
- PAT题目AC汇总(待补全)
题目AC汇总 甲级AC PAT A1001 A+B Format (20 分) PAT A1002 A+B for Polynomials(25) PAT A1005 Spell It Right ( ...
- PAT甲级题解分类byZlc
专题一 字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...
随机推荐
- django的url的name参数的意义及view中reverse
Templates的链接地址都是根据urlpatterns定义的地址,拼凑成地址字符串,很难看,而且Templates里拼凑成的地址,随着页面的增加而不断增加,一旦在urlpatterns里的某个地址 ...
- 中国MOOC_零基础学Java语言_第2周 判断
浮点数判断大小 public class Main { public static void main(String[] args) { double a = 1.0; double b = 0.1 ...
- sql 、linq、lambda 查询语句
http://www.cnblogs.com/lei2007/archive/2011/07/21/2113161.html
- C++/C# 转化 Marshal VS Ptr
Vidyo32.VidyoClientInEventLogin Login = new Vidyo32.VidyoClientInEventLogin(); Login.portalUri = thi ...
- :hover 鼠标同时触发两个元素变化
HTML代码: <li> <span>4</span> <a href="#">巨型一号丝瓜水320ML</a>< ...
- ElasticSearch入门 —— 集群搭建
一.环境介绍与安装准备 1.环境说明 2台虚拟机,OS为ubuntu13.04,ip分别为xxx.xxx.xxx.140和xxx.xxx.xxx.145. 2.安装准备 ElasticSearch(简 ...
- Scratch少儿编程系列:(九)音乐高级技巧
一.程序说明 本程序用来演奏音乐,相对于“Scratch少儿编程系列:(八)演奏简单音乐”而言,本节介绍的方法适用于复杂点的音乐. 二.程序流程图 为了更直观的描述上述过程,采用流程图的方式将猜数字的 ...
- 【Qt开发】V4L2 API详解 背景知识 打开设备设置参数
www.linuxtv.org下,有篇文档详细讲解了V4L2相关知识和体系结构.是V4L2方面最全面的文档.可以通过它学习V4L2的一些思路和想法. http://www.linuxtv.org/do ...
- MySQL数据库的特点和优势
MySQL数据库的特点和优势: 1.MySQL性能卓越.服务稳定,很少出现异常宕机. 2.MySQL开放源代码且无版权制约,自主性及使用成本低. 3.MySQL历史悠久,用户使用活跃,遇到问题可以寻求 ...
- 关于XML的一些事
XML:可扩展标记语言! 01.很像HTML 02.着重点是数据的保存 03.无需预编译 04.符合W3C标准 可扩展:我们可以自定义,完全按照自己的规划来! 标记:计算机所能认识的信息符号! 比如: ...