#include <stdio.h> #include <string.h> void deblank(char string[]) { const int tmp=strlen(string); for (int i = 0; i <=tmp; ++i) { if (string[i]==‘ ‘) { if (string[i+1]==‘ ‘) { for (int j = i+1;j<=tmp;j++) string[j]=string[j+1]; i--; continue; } } else continue; } } int main(void) { char chars[1000]; gets(chars); deblank(chars); for (int i = 0; i < strlen(chars); ++i) { printf("%c",chars[i]); } return 0; }
时间: 2024-10-10 07:57:20