12073 - character replacement   

Description

There will be some sample code for this problem . 

 

The first line contains a string s.

There will be only lowercase Latin characters in s.

The second line will be an integer T, which is the change time. And T< 107.

For the next T line , each line will contains two character x, y , which means for any x in s should be replacement as y .

 

1.    This problem involves three files.
  • function.h: Function definition of changeCharacter.
  • function.c: Function describe of changeCharacter.
  • main.c: A driver program to test your implementation.
You will be provided with main.cpp and function.h, and asked to implement function.cpp.
 
main.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "function.h"
 
#define STRING_SIZE 10000
char input_str[STRING_SIZE];
 
int main() {
    char a, b;
    scanf("%s", input_str);
 
    int T;
    scanf("%d", &T);
    while (T--) {
        scanf("%c", &a);
        scanf("%c %c", &a, &b);
        changeCharacter(input_str, a, b);
    }
    printf("%s\n", input_str);
}
 
function.h
#ifndef __FUNCTION_H__
#define __FUNCTION_H__
 
// Please implement this function in another C cource code
int changeCharacter(char *str, char a, char b);
 
#endif
 
2.    For OJ submission:
 
       Step 1. Submit only your function.c into the submission block.
 
       Step 2. Check the results and debug your program if necessary.

 

Input

| s | < 10000

x, y will be  lowercase Latin characters 

 

For the testcase one , there is  no change to original string s.

If you get any Runtime error in testcase one, think twice what's wrong with your pointer :D .

Output

In the end , output the string s one time !

Note: remember to print a '\n' at the end of output.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12073.c

Partial Judge Header

12073.h

Tags




Discuss