イリヤ 2018-11-29 15:57 采纳率: 0%
浏览 2514
已采纳

编写函数del(char str[])将字符串str中的小写字母删除

//编写函数del(char str[])将字符串str中的小写字母删除。编写主函数,在主函数中定义字符数组s[80],从键盘输入一字符串给s,通过调用函数del,将字符数组s中的小写字母删除,并输出删除后的字符串
#include "stdio.h"
#include "stdlib.h"
main()
{char s[80];
gets(s);
del(s);
printf("\n%s", s );
system("pause");

}
del(char str[])
{/************found************/

}//大佬能用萌新看得懂的语句写吗,刚刚学han'shu

  • 写回答

2条回答 默认 最新

  • threenewbee 2018-11-29 16:09
    关注
    #include "stdio.h"
    #include "stdlib.h"
    void del(char str[]);
    
    int main()
    {char s[80];
    gets(s);
    del(s);
    printf("\n%s", s );
    system("pause");
    }
    void del(char str[])
    {/************found************/
        int i = 0;
        int j = 0;
        while (str[j] != '\0')
        {
            if (str[j] < 'a' || str[j] > 'z')
                str[i++] = str[j];
            j++;
        }
        str[i] = '\0';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?