下面是完整程序:

#include "stdio.h" #include "stdlib.h"

int main() { char s[80], j, i; gets(s); for (i = 0, j = 0; s[i] != '\0'; i++) { if (s[i] >= 'a' && s[i] <= 'z') // 判断是否为小写字母 { s[j] = s[i]; j++; } } s[j] = '\0'; printf("%s", s); system("pause"); return 0; }

注:在 ASCII 码表中,小写字母 a 的 ASCII 码为 97,小写字母 z 的 ASCII 码为 122。因此,可以直接使用 'a' 和 'z' 表示小写字母范围。

下面程序的功能是将字符串中的小写字母删除后输出。请完善函数#include stdioh#include stdlibhmain char s80ji; getss; fori=0j=0;si!=0;i++found ifsi=97&&si=122 sj=si; j++; found sj=0 ;found printfnssj; systempause;

原文地址: https://www.cveoy.top/t/topic/bDel 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录