1 条题解
-
0
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; }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = null; StringBuffer temp = new StringBuffer(); boolean flag = false; int count = 0; while (in.hasNext()) { str = in.nextLine(); char[] ch = str.toCharArray(); for (int i = 0; i < ch.length; i++) { if (ch[i] >= 'A' && ch[i] <= 'Z') { flag = true; temp.append(ch[i]); } } System.out.println("Case #" + ++count + ":"); if (flag) { System.out.println(temp); flag = false; temp.delete(0,temp.length()); } else { System.out.println("NO"); } System.out.println(); } } }
- 1
信息
- ID
- 1128
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者