网友您好, 请在下方输入框内输入要搜索的题目:
Misspelling is an art form that students seem to excel at. Write a program that removes the nth character from an input string. InputThe first line of input contains a single integer N, (1 <= N <= 1000) which is the number of datasets that follow. Each dataset consists of a single line of input containing M, a space, and a single word made up of uppercase letters only. M 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. OutputFor 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. Sample Input44 MISSPELL1 PROGRAMMING7 CONTEST3 BALLOONSample Output1 MISPELL2 ROGRAMMING3 CONTES4 BALOON我的代码#include<stdio.h>#include<string.h>int main(){ int n,i,m,k,j,char[90]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&m); getchar(); scanf("%s",&ch); j=0; for(k=0;ch[k]!='\0';k++) { if(k!=(m-1)) { j=j+1; ch[j]=ch[k]; // 这个地方 我有点小疑问 如果m=4 那么 ch[1]=ch[0],ch[2] } ]=ch[1] ch[3]=ch[2] ch[4]=ch[4];ch[5]=ch[5]....... 最后 在 } 输出ch的时候 ch[0] =ch[1],这个地方不是会有重复吗? (新手问的问题可能有点白痴 呵呵) printf("%d\n",k+1); printf("%s\n",ch); } return 0;}
参考答案