zoukankan      html  css  js  c++  java
  • HDU

    题意:给定一个,其实是由一个图按蛇形输出而成的字符串,要求按从左到右,从上到下的顺序输出这个图。

    分析:

    1、把字符串转化成图

    2、按要求输出图= =

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<cmath>
    #include<iostream>
    #include<sstream>
    #include<iterator>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<set>
    #include<map>
    #include<stack>
    #include<deque>
    #include<queue>
    #include<list>
    #define lowbit(x) (x & (-x))
    const double eps = 1e-8;
    inline int dcmp(double a, double b){
        if(fabs(a - b) < eps) return 0;
        return a > b ? 1 : -1;
    }
    typedef long long LL;
    typedef unsigned long long ULL;
    const int INT_INF = 0x3f3f3f3f;
    const int INT_M_INF = 0x7f7f7f7f;
    const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
    const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
    const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
    const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
    const int MOD = 1e9 + 7;
    const double pi = acos(-1.0);
    const int MAXN = 200 + 10;
    const int MAXT = 10000 + 10;
    using namespace std;
    char s[MAXN];
    char pic[MAXN][MAXN];
    int main(){
        int c;
        while(scanf("%d", &c) == 1){
            if(!c) return 0;
            memset(pic, ' ', sizeof pic);
            scanf("%s", s);
            int len = strlen(s);
            int r = 0;
            for(int i = 0; i < len; ++i){
                if(i % c == 0) ++r;
                if(r & 1){
                    pic[r][i - (r - 1) * c] = s[i];
                }
                else{
                    pic[r][c - (i - (r - 1) * c) - 1] = s[i];
                }
            }
            for(int i = 0; i < c; ++i){
                for(int j = 1; j <= r; ++j){
                    printf("%c", pic[j][i]);
                }
            }
            printf("
    ");
        }
        return 0;
    }
    

      

  • 相关阅读:
    使用NDK编译 libyuv <转>
    x264中重要结构体参数解释,参数设置,函数说明 <转>
    x264的一些参数设置对编码效率的影响
    首都儿研所开钙片!!!
    Android 媒体编解码器(转)
    opengl版本和扩展
    ffmpeg一揽子
    Android 使用SWIG生成Jni代码<转>
    CF 19D 线段树+set压缩坐标轴+离散化map
    android4.0 FaceDetection笔记
  • 原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/6749962.html
Copyright © 2011-2022 走看看