zoukankan      html  css  js  c++  java
  • hdu To and Fro

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1200

    代码:

     1 #include <stdio.h>
     2 #include <string.h>
     3 #include <math.h>
     4 #include <algorithm>
     5 #include <iostream>
     6 #include <ctype.h>
     7 #include <iomanip>
     8 #include <queue>
     9 #include <map>
    10 #include <stdlib.h>
    11 using namespace std;
    12 
    13 char a[25][250],str[300];
    14 
    15 int main()
    16 {
    17     int lie,hang;
    18     int len,i,j,k;
    19     while(scanf("%d",&lie),lie){
    20         getchar();
    21         hang=k=0;
    22         memset(a,'',sizeof(a));//将字符数组初始化  
    23         gets(str);
    24         len=strlen(str);
    25         hang=len/lie;
    26         for(i=0;i<hang && k<len;i++){//将一开始输入的字符按照先从左到右,再从右到左填入二维数组中  
    27             for(j=0;j<lie;j++){
    28                 if(i%2)//判断是奇数行  
    29                     a[i][lie-j-1]=str[k++];
    30                 else
    31                     a[i][j]=str[k++];
    32             }
    33         }
    34         for(i=0;i<lie;i++)//按顺序输出就可以了,注意是从上到下输出  
    35                 for(j=0;j<hang;j++)
    36                     printf("%c",a[j][i]);
    37             printf("
    "); 
    38     }
    39 }
  • 相关阅读:
    day63_django_html
    day62_django
    day20
    diango_自定义标签问题
    day64_django_orm
    day16_函数嵌套及对象
    day60_django
    pip 安装问题
    day13_文件操作
    文本溢出显示省略号(…) 小坦克
  • 原文地址:https://www.cnblogs.com/wangmengmeng/p/4874997.html
Copyright © 2011-2022 走看看