Skip to content

Instantly share code, notes, and snippets.

@waitonza
Created February 4, 2013 02:51
Show Gist options
  • Save waitonza/4704765 to your computer and use it in GitHub Desktop.
Save waitonza/4704765 to your computer and use it in GitHub Desktop.
parenref of codejom 2013
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
char tmp[10000];
void solve_by_line(){
scanf("%[^\n]%*[\n]",tmp);
for (int i = strlen(tmp); i >= 0 ; i--) {
if (tmp[i] == '(') {
printf(")");
} else if (tmp[i] == ')') {
printf("(");
}
}
printf("\n");
}
int main(){
//File Name
char filename[100] = "parenref-1";
char file_in[100] = "";
char file_out[100] = "";
strcpy(file_in, filename);
strcpy(file_out, filename);
strcat(file_in, ".in");
strcat(file_out, ".out");
//File input
freopen(file_in,"r",stdin);
//File output
freopen(file_out,"w",stdout);
int n;
scanf("%d%*[\n]",&n);
//memset(prime, 0, sizeof(prime));
for(int i=1;i<=n;i++){
solve_by_line();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment