C语言实现英文名称缩略语转换 - 将“world wide web”转换为“WWW”
#include <stdio.h>\n#include <ctype.h>\n\nvoid abbr(char s1, char s2);\n\nint main() {\n char s1[100], s2[100];\n \n printf("Enter a string: ");\n gets(s1);\n \n abbr(s1, s2);\n \n printf("Abbreviation: %s\n", s2);\n \n return 0;\n}\n\nvoid abbr(char s1, char s2) {\n int i, j = 0;\n \n for(i = 0; s1[i] != '\0'; i++) {\n if(s1[i] == ' ' && s1[i+1] != ' ') {\n s2[j] = toupper(s1[i+1]);\n j++;\n }\n }\n \n s2[j] = '\0';\n}
原文地址: https://www.cveoy.top/t/topic/pEFd 著作权归作者所有。请勿转载和采集!