Skip to content

Latest commit

 

History

History
30 lines (27 loc) · 433 Bytes

32.md

File metadata and controls

30 lines (27 loc) · 433 Bytes

题目:删除一个字符串中的指定字母,如:字符串 "aca",删除其中的 a 字母。

#include<stdio.h>

int main()
{
	char s[256];
	scanf("%s", s);
	printf("删除字母:");
	char c;
	getchar();
	scanf("%c", &c);
	for (int i = 0; s[i] != '\0'; ++i)
	{
		if (s[i] == c)
		{
			int j;
			for (j = i; s[j] != '\0'; ++j)
			{
				s[j] = s[j + 1];
			}
			s[j] = '\0';
		}
	}

	printf("%s", s);

	return 0;
}