请问一下各位,对于刚刚学c语言,这个问题要怎么解决

img

img


对于如何正确输入字符存在疑问,而且不知道该如何避免结束输入时的空格与字符里的空格混在一起

img

#include<stdio.h>
int main()
{
    int digit, i, letter, N, other, blank;
    char ch;
    digit = letter = other = blank = 0;
    scanf("%d", &N);
    getchar();
    for(i = 1; i<=N; i++){
        ch = getchar();
        if((ch>='a'&& ch<='z')||(ch>='A'&& ch<='Z')){
            letter++;
        }else if(ch>='0'&& ch<='9'){
            digit++;
        }else if(ch==' '|| ch=='\n'){
            blank++;
        }else{
            other++;
        }
    }
    printf("letter = %d, blank = %d, digit = %d, other = %d\n", letter, blank, digit, other);
    
    return 0;
}