字串-保留字母

HowieLee59發表於2019-03-17

Problem Description

編一個程式,輸入一個字串,將組成字串的所有非英文字母的字元刪除後輸出。

Input

一個字串,長度不超過80個字元。

Output

刪掉非英文字母后的字串。

Sample Input

abc123+xyz.5

Sample Output

abcxyz
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
    char str[100];
    scanf("%s",str);
    for(int i = 0 ; str[i] != '\0'; i++){
        if((str[i] >= 'a' && str[i] <= 'z') || (str[i]>='A'&& str[i]<='Z'))
            printf("%c",str[i]);
    }
    printf("\n");

}

 

相關文章