求解答,不知道为啥输出是跳过一个字符的

  1. 白夜的强迫症
    白夜有强迫症,他看到一串大小写混杂的字符串就会不开心。如果他看到这样的字符串,他会选择把它修改成全部大写或者全部小写。但他又不想在这上面花费太多的时间,所以他想修改最少的次数达到他的目的。给定一个字符串,你能推断出他修改后的字符串是什么样子的吗?
    P.S.:如果改成全部大写和改成全部小写的修改次数一样,这两种情况都有可能,你可以选择任意输出一个或者全部输出

输入:一个仅含英文字母的字符串 输出:修改后的字符串
例如输入:HelloWorld 输出:helloworld

#include
#include
int main()
{
    char a[100],ch;
    int i=0,b=0,s=0,net=0;
    do 
    {
        scanf("%1c",&a[i]);
        if(a[i]>='a'&&a[i]<='z')
        {
            s++;
        }
        if(a[i]>='A'&&a[i]<='Z')
        {
            b++;
        }
        i++;
    }while(getchar()!='\n');
    if(b>=s)
    {
        for(net=0;nettoupper(a[net]);
        printf("%c",ch);
        }
    }
    if(bfor(net=0;nettolower(a[net]);
        printf("%c",ch);
        }
    }
 } 
 
 
 
 
 
 
 
 

因为scanf("%1c",&a[i]);会将换行读入
输入字符串还是一次性读入使用%s比较好

#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main()
{
    char a[100],ch;
    int i=0,b=0,s=0,net=0;
    scanf("%s",a);
    int len = strlen(a);
    for(int i = 0;i < len;i++){
        if(a[i] >= 'a' && a[i] <= 'z'){
            s++;
        }else if(a[i] >= 'A' && a[i] <= 'Z'){
            b++;
        }
    }
    i = len;
    if(b>=s)
    {
        for(net=0;net<i;net++)
        {
            ch= toupper(a[net]);
            printf("%c",ch);
        }
    }
    if(b<s)
    {
        for(net=0;net<i;net++)
        {
            ch= tolower(a[net]);
            printf("%c",ch);
        }
    }
 } 
 
#include<stdio.h>

int main()

{

int a;

char ch;

scanf("%d",&a);

ch=a;

printf("%c",ch);

return 0;

}