MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

Codeforces_problems/decoding/solution.cpp:26–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24#include<bits/stdc++.h>
25using namespace std;
26int main()
27{
28 int n; //define length vriable
29 cin>>n; //tajing length vriable
30 string s,s1; //define two strings
31 cin>>s; //taking the cncoded string
32 s1=s[0]; //start transform it to the original form
33 if(n%2==0){ //we check if the length is even
34 for(int i=1;i<n;i++){ //we loop through the string elements of the endcoded one
35 if(i%2!=0) s1+=s[i]; //we add it in the second and swap this step it the next iteration
36 else s1=s[i]+s1; //we add it in the first and swap this step it the next iteration
37 }
38 }
39 else{
40 for(int i=1;i<n;i++){//the same as even but with different coditions to start with te right condition only
41 if(i%2==0) s1+=s[i];
42 else s1=s[i]+s1;
43 }
44 }
45 cout<<s1;
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected