词组缩写 HDU-2564

xiaoxiao2021-02-28  64

题意: t组数据,每组数据1行,每行有若干个单词,要求输出所有单词的首字母(大写输出)

思路:很简单

错误分析:没注意到第一个单词可能是前面有空格的情况。 比较坑爹一直PE

#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(void) { int t; cin >> t; getchar(); while(t--) { char str[600]; gets(str); if(isalpha(str[0])) printf("%c",toupper(str[0])); for(int i=1;i<strlen(str);i++) { if(str[i]==' ' && str[i+1]!=' ') { if(isalpha(str[i+1])) printf("%c",toupper(str[i+1])); } } puts(""); } }
转载请注明原文地址: https://www.6miu.com/read-78842.html

最新回复(0)