Misspelling

From Progteam

Revision as of 01:56, 22 February 2008 by Mlc413 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Misspelling
Problem Number A
Sorter: Mlc413
Source: GNYR ICPC 2007
Link: "http://www.acmgnyr.org/year2007/a.pdf"
Checkmark.jpg This problem has been solved by Mlc413.


This was problem A from the GNYR ICPC 2007.

The goal is to insert spelling errors into a word by removing the letter indicated by the input data.

Solution involves basic string manipulation.


import java.util.*;

public class Main{
    public static Scanner in;
    public static void main(String[] args){
	in = new Scanner(System.in);
	doStuff();
    }
 
    public static void doStuff(){
	int N = in.nextInt();
	for(int i = 1; i <=N; i++){
	    System.out.print(i+" ");
	    solve(in.nextInt(), in.next());
	    
	}

    }

    public static void solve(int M, String str){
	int len = str.length();
	String newStr = str.substring(0, M-1) + str.substring(M, len);
	System.out.print(newStr + "\n");
    }
    
}


Personal tools