1 solutions
-
0
C :
#include<stdio.h> int main() { int n,i,k; char a[200],b,c; #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif scanf("%d\n",&n); while(n--) { i=0;k=0; gets(a); for(i=0;a[i]!='\0';i++) { if(a[i]==' ') k=0; else { if(k==0) { if(a[i]>='a') a[i]-=32; printf("%c",a[i]); k=1; } else { k=1; } } } printf("\n"); } return 0; }C++ :
/* 这一题很简单,用来练习字符串处理函数正好。 */ #include<stdio.h> #include<string.h> #include<ctype.h> int main() { int t; char c[101]; int k,i; char * temp[10]; scanf("%d\n",&t); for(k=0;k<t;k++) { gets(c); temp[0]=strtok(c," "); printf("%c",toupper(temp[0][0])); for(i=1;i<10;i++) { temp[i]=strtok(NULL," "); if(temp[i]==NULL)break; printf("%c",toupper(temp[i][0])); } printf("\n"); } return 0; }Java :
import java.util.Scanner; import java.util.StringTokenizer; public class Main{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int T = in.nextInt(); in.nextLine(); while(T-- != 0){ StringTokenizer s = new StringTokenizer(in.nextLine(), " "); while(s.hasMoreTokens()){ System.out.print(((s.nextToken()).toUpperCase()).charAt(0)); } System.out.println(); } } }
- 1
Information
- ID
- 1325
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By