首页 > 其他 > 详细

HDU2564 词组缩写

时间:2019-06-03 15:16:15      阅读:122      评论:0      收藏:0      [点我收藏+]

2019-06-03

15:00:38

感觉有有种被坑了的感觉,这道题不难,就是一再的W,??

 

第一:题目要求多组输入,怎……么看出来的??

第二:我现在都还没弄懂,好像知道那个样例啊!!!??

else if (a[0] >= A && a[0] <= Z)
              {
                   cout << a[0];
              }
难道不可以直接else吗???看到的可以给我发一下评论,谢谢!!
 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int t;
 6     while (cin >> t)
 7     {
 8         getchar();
 9         while (t--)
10         {
11             string a;
12             getline(cin, a);
13             
14             int lenth = a.length();
15             if (a[0] >= a && a[0] <= z)
16             {
17                 printf("%c", a[0] - 32);
18             }
19             else if (a[0] >= A && a[0] <= Z)
20             {
21                 cout << a[0];
22             }
23 
24             for (int i = 1; i < lenth; i++)
25             {
26                 if (a[i - 1] ==   && a[i] >= a && a[i] <= z)
27                 {
28                     printf("%c", a[i] - 32);
29                 }
30                 if (a[i - 1] ==   && a[i] >= A && a[i] <= Z)
31                 {
32                     printf("%c", a[i]);
33                 }
34             }
35             cout << endl;
36         }
37     }
38     return 0;
39 }

 

#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
while (cin >> t)
{
getchar();
while (t--)
{
string a;
getline(cin, a);
 
int lenth = a.length();
if (a[0] >= ‘a‘ && a[0] <= ‘z‘)
{
printf("%c", a[0] - 32);
}
else if (a[0] >= ‘A‘ && a[0] <= ‘Z‘)
{
cout << a[0];
}

for (int i = 1; i < lenth; i++)
{
if (a[i - 1] == ‘ ‘ && a[i] >= ‘a‘ && a[i] <= ‘z‘)
{
printf("%c", a[i] - 32);
}
if (a[i - 1] == ‘ ‘ && a[i] >= ‘A‘ && a[i] <= ‘Z‘)
{
printf("%c", a[i]);
}
}
cout << endl;
}
}
return 0;
}

HDU2564 词组缩写

原文:https://www.cnblogs.com/Artimis-fightting/p/10967671.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!