Example #1
0
int main()
{
    Solution solution;
    
    //Test cases
    {
        string s = "PAYPALISHIRING";
        int n = 3;

        cout << solution.convert(s, n) << endl;
    }
	
    {
        string s = "abcdefghigklmasdfasdfasdfasdfasdf";
        int n = 5;

        cout << solution.convert(s, n) << endl;
    }

    //Error test cases from leetcode.com
    {
        string s = "PAYPALISHIRING";
        int n = 2;

        cout << solution.convert(s, n) << endl;
    }
	
	return 0;
}
int main() {
	Solution s;
	cout << s.convert("PAYPALISHIRING", 3) << endl;
	cout << s.convert("ABCD", 2) << endl;
	cout << s.convert("AB", 1) << endl;
	cout << s.convert("ABCD", 1) << endl;
	cout << s.convert("Apalindromeisaword,phrase,number,orothersequenceofunitsthatcanbereadthesamewayineitherdirection,withgeneralallowancesforadjustmentstopunctuationandworddividers.", 1) << endl;
}
Example #3
0
void test() {
    Solution s = Solution();
//     Input: s = "PAYPALISHIRING", numRows = 3
//     Output: "PAHNAPLSIIGYIR"
    cout <<"test1 result: " << s.convert("PAYPALISHIRING", 3) << endl;

// Input: s = "PAYPALISHIRING", numRows = 4
// Output: "PINALSIGYAHRPI"
    cout <<"test2 result: " << s.convert("PAYPALISHIRING", 4) << endl;
}
int main() {
    Solution s;
    std::string input = "PAYPALISHIRING";
    std::cout << s.convert(input, 3) << std::endl;
    input = "ABC";
    std::cout << s.convert(input, 2) << std::endl;
    input = "ABCD";
    std::cout << s.convert(input, 1) << std::endl;
    string input1 = "AB";
    std::cout << s.convert(input1, 3) << std::endl;
    std::cout << (-1)/2 << std::endl;
}
Example #5
0
int main() {
    Solution sol;
    int nRows = 3;
    string text = "PAYPALISHIRING";
    //string text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    //string text = "ABCD";
    //string text = "A";
    //string text = "";
    cout << "Before conversion: " << text << endl;
    cout << "Text size before conversion: " << text.size() << endl;
    cout << "After conversion with nRows = " << nRows << ": " << sol.convert(text, nRows) << endl;
    cout << "Text size after conversion: " << sol.convert(text, nRows).size() << endl;
}
Example #6
0
int main() {
  std::string test;
  Solution a;
  test = a.convert("PAYPALISHIRING", 3);
  std::cout << test << std::endl;
  return 0;
}
int main()
{
    Solution s;
  //  cout<<s.convert("ABCDEFGHIJKLMNOPQRST", 5)<<endl;
   cout<<s.convert("abc", 2)<<endl;
    return 0;
}
Example #8
0
int main() {
	string s = "PAYPALISHIRING";
	Solution so;
	cout << so.convert(s, 3);

	return 0;
}
Example #9
0
int main(void)
{
    Solution sol;
	cout<<sol.convert("PAYPALISHIRING",3)<<endl;
	cout<<"PAHNAPLSIIGYIR"<<endl;
    return 0;
}
Example #10
0
int main(){
	string str = "PAYPALISHIRING";
	Solution s;
	string res = s.convert(str, 3);
	cout<<res<<endl;
	return 0;
}
int main()
{
    Solution sol;
    string s = "PAYPALISHIRING";
    cout << sol.convert(s,3) << endl;
    return 0;
}
Example #12
0
int main()
{
    Solution s;
    cout << s.convert("PAYPALISHIRING", 3);
    
    return 0;
}
Example #13
0
int main() {
    Solution s;
    string ret;
    string str = "PAYPALISHIRING";

    ret = s.convert(str, 3);
    cout << ret << endl;
}
int main(){
    string s = "twckwuyvbihajbmhmodminftgpdcbquupwflqfiunpuwtigfwjtgzzcfofjpydjnzqysvgmiyifrrlwpwpyvqadefmvfshsrxsltbxbziiqbvosufqpwsucyjyfbhauesgzvfdwnloojejdkzugsrksakzbrzxwudxpjaoyocpxhycrxwzrpllpwlsnkqlevjwejkfxmuwvsyopxpjmbuexfwksoywkhsqqevqtpoohpd";
    int numRows = 4;
    
    Solution newSolution;
    cout << newSolution.convert(s, numRows) << endl;
    return 0;
}
Example #15
0
int main() {
    Solution a;
    string s;
    int n;
    while (cin >> s >> n)
        cout << a.convert(s, n) << endl;
    return 0;
}
Example #16
0
int main()
{
    string strRows = "A";
    int numRows = 1;
    Solution sol;
    string str = sol.convert(strRows, numRows);
    return 0;
}
int main() {
	string input = "A";
	int numRows = 1;

	Solution sol;
	string ans = sol.convert(input, numRows);
	cout << ans << endl;
}
static void test_func(string str, int rows)
{
	Solution s;
	string ret;

	ret = s.convert(str, rows);
	cout << str << "->" << ret << endl;
}
Example #19
0
int main(void)
{
    Solution solu;

    std::cout <<solu.convert("PAYPALISHIRING", 3) <<std::endl;

    return 0;
}
Example #20
0
int main()
{
	Solution sol;
	string s = "ABCD";
	string out = sol.convert(s,4);
	cout << out << endl;

	return 0;
}
Example #21
0
int main(){
    string s;
    int numRows;
    cin >> s;
    cin >> numRows;
    Solution solution;
    cout << solution.convert(s, numRows) << endl;
    return 0;
}
Example #22
0
int main(int argc, const char * argv[]) {
    Solution *S =  new Solution();
    string result = S->convert("ABCDE", 4);
    cout << result << endl;
//    for (int i = 0; i < result.size(); i++) {
//        cout << result[i] << endl;
//    }
    return 0;
}
Example #23
0
int main() {
	string s;
	int row;
	Solution solution;
	while (cin >> s >> row) {
		cout << solution.convert(s, row) << endl;
	}
	return 0;
}
Example #24
0
int main(int argc, char** argv) {
    string str;
    int n;
    cin >> str >> n;
    Solution mySolution;
    string result = mySolution.convert(str, n);
    cout << result << endl;
    return 0;
}
int main()
{
	string s;
	s = "PAYPALISHIRING";
	Solution sol;
	int numRows;
	cin >> numRows;
	sol.convert(s, numRows);
	return 0;
}
Example #26
0
int main() {


  Solution demo = Solution();

  string s;
  int numRows;

  string rel;

  s  = "PAYPALISHIRING";
  numRows = 3;
  rel = demo.convert(s, numRows);
  cout<<"input :"<<s<<endl;
  cout<<"output:"<<rel<<endl;

  s  = "";
  numRows = 2;
  rel = demo.convert(s, numRows);
  cout<<"input :"<<s<<endl;
  cout<<"output:"<<rel<<endl;
}
void test(){
    Solution work;
    string ans;
    string input;

    input = "PAYPALISHIRING";
    ans = work.convert(input, 3);
    printf("input=%s\nans=%s\n", input.c_str(), ans.c_str());


    input = "PAYPALISHIRING";
    ans = work.convert(input, 2);
    printf("input=%s\nans=%s\n", input.c_str(), ans.c_str());



    input = "PAYPALISHIRING";
    ans = work.convert(input, 22);
    printf("input=%s\nans=%s\n", input.c_str(), ans.c_str());

    input = "A";
    ans = work.convert(input, 1);
    printf("input=%s\nans=%s\n", input.c_str(), ans.c_str());
}
int _tmain(int argc, _TCHAR* argv[])
{
    using namespace std;

    string s = "PAYPALISHIRING";
    int rows = 3;
    Solution so;

    while (cin >> s)
    {
        cin >> rows;

        cout << so.convert(s, rows) << endl;
        cout << "----------------------------------" << endl;
    }


	return 0;
}
Example #29
0
int main(int argc, char** argv) {
    string inputFileName = DEFAULT_INPUT_FILENAME;
    string outputFilename = DEFAULT_OUTPUT_FILENAME;
    if (argc < 2)  {
        cout << "Usage: blah.exe filename.xxx" << endl;
    } else {
        inputFileName = argv[1];
        if (argc == 3) { outputFilename = argv[2]; }
    }
    cout << "importing from FILE:   " << inputFileName  << endl;
    cout << "SAVING RESULT TO FILE: " << outputFilename << endl;

    Solution solver;

    // read input file and process along
    ifstream inFile(inputFileName, ios::in);
    if (inFile.is_open()) {
        string line_str;
        // Read in line by line
        while (getline(inFile, line_str)) {
            stringstream line_stream(line_str);
            string text;
            line_stream >> text;
            int rownum;
            line_stream >> rownum;
            string expectedstr;
            line_stream >> expectedstr;

            string zigzagstr = solver.convert(text, rownum);
            if (zigzagstr != expectedstr) { // wrong restult!
                cout << endl << "WRONG RESULT: " << endl;
            }
        }

        inFile.close();
    }
Example #30
0
void main() {
	Solution s;
	cout<<s.convert("PAYPALISHIRING", 3)<<endl;
	system("pause");
}