Created
March 24, 2017 16:57
-
-
Save residentkrm/9c78dbba934eccb84c8b03b2c19d20be to your computer and use it in GitHub Desktop.
check1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
string str; | |
getline(cin, str); | |
int n; | |
cin >> n; | |
for (int it = 0; it < n; ++it) | |
{ | |
string str2; | |
string str3; | |
for (int i = 0; i < str.length(); ++i) | |
{ | |
if (i % 2 == 0) | |
str2 += str[i]; | |
else | |
str3 += str[i]; | |
} | |
std::reverse(str2.begin(), str2.end()); | |
std::reverse(str3.begin(), str3.end()); | |
str = str3 + str2; | |
cout << str << endl; | |
} | |
int m; | |
cin >> m; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int n; | |
String str = ""; | |
str = Console.ReadLine(); | |
n = int.Parse(Console.ReadLine()); | |
for (int it = 0; it < n; ++it) | |
{ | |
string str2 = ""; | |
string str3 = ""; | |
for (int i = 0; i < str.Length; ++i) | |
{ | |
if (i % 2 == 0) | |
str2 += str[i]; | |
else | |
str3 += str[i]; | |
} | |
str2 = new String(str2.Reverse().ToArray()); | |
str3 = new String(str3.Reverse().ToArray()); | |
str = str3 + str2; | |
Console.WriteLine(str); | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.EOFException; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.ObjectInputStream; | |
import java.io.ObjectOutputStream; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Scanner; | |
public class Task1 | |
{ | |
public static void main(String... args) | |
{ | |
Scanner scan = new Scanner(System.in); | |
String str; | |
str = scan.nextLine(); | |
int n; | |
n = scan.nextInt(); | |
for (int it = 0; it < n; ++it) | |
{ | |
String str2 = ""; | |
String str3 = ""; | |
for (int i = 0; i < str.length(); ++i) | |
{ | |
if (i % 2 == 0) | |
str2 += str.toCharArray()[i]; | |
else | |
str3 += str.toCharArray()[i]; | |
} | |
StringBuffer buf = new StringBuffer(str2); | |
StringBuffer buf2 = new StringBuffer(str3); | |
str2 = buf.reverse().toString(); | |
str3 = buf2.reverse().toString(); | |
str = str3 + str2; | |
System.out.println(str); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment