3921 - 重写字符串
把给出的字符串,挑出其中的大写字母,重新组成一个新串
如果不存在大写字母就输出"NO"
Input
每组测试数据输入一行字符串,只包含大小写字母
Output
每组测试数据先输出,Case #x: y
再在接下来的一行输出答案
每组测试数据间保留一个空行
Examples
Input
AdsDCSADdsa
Output
Case #1: ADCSAD
Solution C++
#include <cstdio> #include <cstring> #define MAXN 10000000 char str[MAXN]; int main(){ int x=1; while(scanf("%s",&str)!=EOF){ int count=0; printf("Case #%d:\n",x++); for(int i=0;str[i];i++){ if(str[i]>='A'&&str[i]<='Z'){ printf("%c",str[i]); count++; } } if(count==0){ printf("NO"); } printf("\n\n"); } return 0; }