将下标为偶数的字符变成大写
#include <stdio.h>
#include <string.h>
#define MAX 100

void fun(char s[])
{
    int i,len;
    len = strlen(s);
    for(i=1;i<len;i+=2)            //对下标是偶数的字符进行转换
    {
        if(s[i]>='a' && s[i]<='z')            //判断是否为字母
        {
            s[i] -= 32;
        }
    }
}

int main()
{
    char str[MAX];
    while(gets(str)!=NULL)
    {
        fun(str);
        puts(str);            //输出字符串        
    }
    return 0;

}

字符串处理

相关文章:

  • 2021-11-18
  • 2021-06-18
  • 2022-02-27
猜你喜欢
  • 2022-01-18
相关资源
相似解决方案