1031. Hello World for U (20)
来源:互联网 发布:淘宝steam离线游戏 编辑:程序博客网 时间:2024/05/28 20:20
点击打开链接
貌似n=9错了
#include <iostream>#include <stdio.h>#include <string.h>#include <string>using namespace std;char c[10000];char s[10000][10000];int main(){freopen("in.txt","r",stdin);gets(c);int n=strlen(c)-2;int max=0;int heng;for(int i=1;i<strlen(c);i++){heng=strlen(c)-2*i;if(heng>=3 && heng<=n && i<=heng){max=i;}}heng=strlen(c)-2*max;//max即为n1的值,不包括最后一行int cnt=0;for(int i=0;i<=max;i++){for(int j=0;j<=heng;j++){if(j==heng){s[i][j]='\n';}else{s[i][j]=' ';}}}for(int i=0;i<max;i++){s[i][0]=c[cnt++];}for(int i=0;i<heng;i++){s[max][i]=c[cnt++];}for(int i=max-1;i>=0;i--){s[i][heng-1]=c[cnt++];}for(int i=0;i<=max;i++){printf("%s",s[i]);}return 0;}
0 0
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)-PAT
- 【PAT】1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- PAT 1031. Hello World for U (20)
- PAT 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- PAT 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- 1031. Hello World for U (20)
- LCA 练习题:【POJ3728】The merchant
- 利用Hibernate 3 Interceptor生成审计日志
- Android图形系统之Surface、SurfaceView、SurfaceHolder及SurfaceHolder.Callback之间的联系
- PB 数据窗口对象
- nyoj 483 nightmare
- 1031. Hello World for U (20)
- HDU_1114 Piggy Bank(DP)
- Maximum sum
- Java线程(二):线程同步synchronized和volatile
- 小码奴历险记:码奴的回忆
- 常用mysql优化策略
- mysql数据库设置不区分大小写
- socket通过压缩流传输文件夹
- Java线程(三):线程协作-生产者/消费者问题