Mispelling | ||
题目描述
Misspelling is an art form that students seem to excel at. Write a program that removes the
n <tex2html_verbatim_mark>th character from an input string.
输入格式The first line of input contains a single integer N <tex2html_verbatim_mark>, (1≤N≤1000) <tex2html_verbatim_mark>which is the number of datasets that follow. Each dataset consists of a single line of input containing M <tex2html_verbatim_mark>, a space, and a single word made up of uppercase letters only. M <tex2html_verbatim_mark>will be less than or equal to the length of the word. The length of the word is guaranteed to be less than or equal to 80. 输出格式
For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, and the misspelled word. The misspelled word is the input word with the indicated character deleted.
样例输入4 4 MISSPELL 1 PROGRAMMING 7 CONTEST 3 BALLOON 样例输出1 MISPELL 2 ROGRAMMING 3 CONTES 4 BALOON |
写的好辛苦啊!!!改了好多道!!才正确!!!
// Problem#: 6274 // Submission#: 1623372 // The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License // URI: http://creativecommons.org/licenses/by-nc-sa/3.0/ // All Copyright reserved by Informatic Lab of Sun Yat-sen University //输入数字及单词,使所输入单词的第数字个字母消除。 #include <stdio.h> #include <string.h> int main() { int a,b,i;//定义控制循环次数的变量 int n=1;//定义并初始化输出顺序 char c[80];//定义数组c的长度 scanf("%d",&b);//输入数组长度,控制外循环次数 while(b!=0)//当不为零时继续循环 { scanf("%d ",&a);//输入所需消去字母所在序列数 scanf("%s",c);//输入字符串(单词) printf("%d ",n);//输出序列数 n++; //序列递增 for(i=0;i<strlen(c);i++)//计数循环 { if(i!=a-1)//当循环到所需消去字母的序列处不打印,其他情况打印字母 printf("%c",c[i]); } printf("\n");//换行 b--;//长度递减,直到零结束外循环 } return 0; }