程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> LeetCode ZigZag Conversion

LeetCode ZigZag Conversion

編輯:C++入門知識

LeetCode ZigZag Conversion


The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)

P   A   H   N
A P L S I I G
Y   I   R
And then read line by line: "PAHNAPLSIIGYIR"

Write the code that will take a string and make this conversion given a number of rows:

string convert(string text, int nRows);

convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".



題目描述:

按照之字格式輸入數據,並且按照橫向輸出。

\


<喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+yOfNvKGjPC9wPgo8cD48YnI+CjwvcD4KPHA+veLM4su8wrejujwvcD4KPHA+PGJyPgo8L3A+CjxwPsnobs6qyuTI69DQyv2jrGnOqtDQusU8YnI+CjwvcD4KPHA+uduy7M28z/HRsNXSuebCyaGjPC9wPgo8cD7I57n7yse12jDQ0LrN1+6689K70NDDv7j219a3+9auvOS1xL7gwOvOqjIqbi0yPC9wPgo8cD7I57n7ysfW0Lzk0NCjrMj0uMPQ0MHQusXOqsW8yv3U8tPrz8K49tfWt/u+4MDrMioobi1pLTEpIKOst/HU8sj0zqrG5sr91PLT68/CuPbX1rf7z+C+4MDrMippPC9wPgo8cD48YnI+CjwvcD4KPHA+wP3I56O6PC9wPgo8cD7NvNbQy/nKvqOstdox0NCjrLXa0ru49tfWt/vOqjGjrMHQusXOqjCjrM6qxbzK/aOs1PLT67Xatv649r7gwOvOqjIqo6g1LTEtMaOpPTY8L3A+CjxwPry0z8K49tfWt/vOqjYmIzQzOzE9NzwvcD4KPHA+08nT2je1xNfWt/vB0LrFzqozzqrG5sr9o6zL+dLUz8K49tfWt/u1xMHQusW+4MDrzqoyKjE9MiC8tDcmIzQzOzI9OTwvcD4KPHA+PGJyPgo8L3A+CjxwPjxwcmUgY2xhc3M9"brush:java;">public class Solution { public String convert(String s, int nRows) { String res=""; int len=s.length(); if (nRows <= 1 || len == 0 ||len

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved