A雷同检测
# include<bits/stdc++.h>
using namespace std;
int main()
{
char str[201], str2[201];
gets(str);
gets(str2);
int i=0,n=strlen(str>str2?str:str2);
for (i = 0; i <= n; i++)
{
if (str[i] == str2[i])
printf("%d ", i + 1);
}
return 0;
}
C大小写转换
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[80];
int i = 0;
while (scanf("%s", s) == 1)
{
for (i = 0; i <= strlen(s);i++)
{
if (s[i] >= 'a'&&s[i] <= 'z')s[i] = s[i] - 32;
}
printf("%s\n", s);
}
return 0;
}
D数字反转
#include <stdio.h>
int main() {
int i = 0, old, new = 0;
scanf("%d", &old);
while(old != 0){
new *= 10;
new += old % 10;
old /= 10;
}
printf("%d", new);
return 0;
}
E删除单词后缀
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[200];
int len;
int i;
gets(s);
len = strlen(s);
if (s[len - 2] == 'e'&&s[len - 1] == 'r')
{
s[len - 2] = '\0';
s[len - 1] = '\0';
}
if (s[len - 2] == 'l'&&s[len - 1] == 'y')
{
s[len - 2] = '\0';
s[len - 1] = '\0';
}
if (s[len - 3] == 'i'&&s[len - 2] == 'n'&&s[len - 1] == 'g')
{
s[len - 3] = '\0';
s[len - 2] = '\0';
s[len - 1] = '\0';
}
puts(s);
return 0;
}
F - 判断字符串是否为回文
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s1[100];
gets(s1);
int j,k;
k = strlen(s1);
j = k - 1;
int i = 0;
while (i < j&&s1[i] == s1[j])
{
i++;
j--;
}
if (i >= j)printf("yes");
else printf("no");
return 0;
}