1100
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
string a;
getline(cin, a);
int i = 0;
while (a[i] == ' ')
{
i++;
}
if (a[i] > 90)
{
a[i] -= 32;
cout << a[i];
}
else
{
cout << a[i];
}
for (i; i < a.size(); i++)
{
if (a[i] == ' ')
{
if (a[i + 1] == ' ')
{
continue;
}
if (a[i + 1] > 90)
{
a[i + 1] -= 32;
cout << a[i + 1];
}
else
{
cout << a[i + 1];
}
}
}
}
1101
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main()
{
string str1, str2;
getline(cin, str1);
getline(cin, str2);
int str1_h = ((str1[0] - 48) * 10 + (str1[1] - 48)) * 3600;//时->秒
int str1_m = ((str1[3] - 48) * 10 + (str1[4] - 48)) * 60;//分->秒
int str1_s = ((str1[6] - 48) * 10 + (str1[7] - 48));//秒
int str1_sum = str1_h + str1_m + str1_s;
int str2_h = ((str2[0] - 48) * 10 + (str2[1] - 48)) * 3600;//时->秒
int str2_m = ((str2[3] - 48) * 10 + (str2[4] - 48)) * 60;//分->秒
int str2_s = ((str2[6] - 48) * 10 + (str2[7] - 48));//秒
int str2_sum = str2_h + str2_m + str2_s;
cout << str1_sum - str2_sum;
}
1102
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
getline(cin, a);
for (int i = 0; i < a.size()-1; i++)
{
for (int j = 0; j < a.size() - i - 1; j++)
{
if (a[j] != ' ' && a[j + 1] == ' ')
{
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
for (int i = 0; i < a.size(); i++)
{
cout << a[i];
}
return 0;
}
1103
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
getline(cin, a);
int num = 1;//当一个字母出现时它至少会出现一次
for (int i = 0; i < a.size(); i++)
{
if (a[i] == a[i + 1])
{
num++;
}
if (a[i] != a[i + 1])//当前后不相等时证明相同字母已经结束,开始结算
{
if (num != 1)//如果不分成num==1和num!=1的情况下,aabbbx会变成2a3b1x,而这个1是我们不想要的
{
cout << num;
cout << a[i];
num = 1;
}
else
{
cout << a[i];
}
}
}
return 0;
}
1104
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
getline(cin, a);
int num = 0;//本题思路核心
int i;
for (i = 0; i < a.size(); i++)
{
if (a[i] >= 48 && a[i] <= 57)//判断是否为数字
{
//这题不能像上一题一样设初始值为1,因为字母前面的数字并不确定,比如说,如果是35a的话
//那么先读3,然后再读数字的话,前面的三就要进位,也就是这里用到的*10,如果一直是数字
//的话要一直进位知道下一个出现字母为止
num = num * 10 + (a[i] - 48);
}
if ((a[i] >= 65 && a[i] <= 90) || (a[i] >= 97 && a[i] <= 122))//遇到英文,开始结算
{
if (num == 0)//讨论的方式和上一道题一样
{
cout << a[i];
}
else
{
for (int j = 1; j <= num; j++)
{
cout << a[i];
}
num = 0;
}
}
}
return 0;
}
1105
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a, b;
getline(cin, a);
getline(cin, b);
string c;
c = a + b;
for (int i = 0; i < c.size() - 1; i++)
{
for (int j = i + 1; j <= c.size(); j++)
{
if (c[i] == c[j])
{
c[j] = 0;
}
}
}
string d;
for (int i = 0; i < c.size(); i++)
{
if (c[i] != 0)
{
d += c[i];
}
}
for (int i = 0; i < d.size(); i++)
{
cout << d[i];
}
return 0;
}
1106
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a;
getline(cin, a);
int num = 1;
for (int i = 0; i < a.size(); i++)
{
if (a[i] == ' ' && a[i + 1] != ' ')
{
num++;
}
}
cout << num;
return 0;
}
1107
#include <iostream>
#include <string>
using namespace std;
string s, w = "", ma = "";
int main() {
getline(cin, s);
//循环每个字符
for (int i = 0; i < s.size(); i++) {
//如果是字母,一定是单词的一部分
if (isalpha(s[i])) {
w = w + s[i];
//如果单词结束
if (i == s.size() - 1 || !isalpha(s[i + 1])) {
//cout<<w<<endl;
if (w.size() > ma.size()) ma = w;
w = "";//清空单词存放下一个单词
}
}
}
cout << ma;
return 0;
}
1108
#include<iostream>
using namespace std;
int main() {
int a[20];
int num = 0;
int length = 0;
cin >> num;
while (num / 2)
{
a[length] = num % 2;
length++;
num = num / 2;
}
a[length] = num;
length++;
for (int i = length - 1; i >= 0; i--)
{
cout << a[i];
}
return 0;
}
1109
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n;
cin >> n;
int sum = 0;
int a[4];
a[0] = n / 1000;
a[1] = n % 1000 / 100;
a[2] = n % 1000 % 100 / 10;
a[3] = n % 1000 % 100 % 10;
for (int i = 3; i >= 0; i--)
{
a[i] = (a[i] + 5) % 10;
sum += pow(10, i) * a[i];
}
cout << sum;
return 0;
}