1. 程式人生 > >2018/12/25輸出大寫英文字母

2018/12/25輸出大寫英文字母

7-5 輸出大寫英文字母 (15 分)

本題要求編寫程式,順序輸出給定字串中所出現過的大寫英文字母,每個字母只輸出一遍;若無大寫英文字母則輸出“Not Found”。
輸入格式:

輸入為一個以回車結束的字串(少於80個字元)。
輸出格式:

按照輸入的順序在一行中輸出所出現過的大寫英文字母,每個字母只輸出一遍。若無大寫英文字母則輸出“Not Found”。
輸入樣例1:

FONTNAME and FILENAME
輸出樣例1:

FONTAMEIL
輸入樣例2:

fontname and filrname
輸出樣例2:

Not Found

#include<stdio.h>
int main(void){
	char a[81];
	char b[81];
	int flag, j, i, count;
	for(i = 0;(a[i] = getchar())!='\n';i++){
		b[i] = a[i];
	}
	a[i] = 0;
	count = 0;
	for(i = 0;a[i]!='\0';i++){
		flag = 0;
		if(a[i]>='A'&&a[i]<='Z'){
			for(j = 0;j<i;j++){
				if(b[j] == a[i]){
					flag = 1;
				}
			}
			if(flag == 0){
				printf("%c", a[i]);
				count++;
			}
		}
	}
	if(count == 0){
		printf("Not Found");		
	}
	
	return 0;
}