给定一个只包含小写字母的字符串,请你找到第一个仅出现一次的字符。如果没有,输出"no"。
第一题
输入格式
一个字符串,长度小于 100000
输出格式
输出第一个仅出现一次的字符,若没有则输出"no"。
Sample Input
abcabd
Sample Output
c
第二题
把一个字符串中特定的字符全部用给定的字符替换,得到一个新的字符串。
输入格式
只有一行,由一个字符串和两个字符组成,中间用单个空格隔开。
字符串是待替换的字符串,字符串长度小于等于 30个字符,且不含空格等空白符;
接下来一个字符为需要被替换的特定字符;
接下来一个字符为用于替换的给定字符。
输出格式
一行,即替换后的字符串。
Sample Input
hello-how-are-you o O
Sample Output
hellO-hOw-are-yOu
第三题
输入一行字符,统计出其中数字字符的个数。
输入格式
一行字符串,总长度不超过 255
输出格式
输出为 1行,输出字符串里面数字字符的个数。
Sample Input
Peking University is set up at 1898.
Sample Output
4
第三题
#include<stdio.h>
#include <ctype.h>
int main()
{
char a[100000];
int count=0;
gets(a);
for(int i=0;i<strlen(a);++i){
if(isdigit(a[i])){
++count;
}
}
printf("%d\n",count);
return 0;
}
第一题
#include<stdio.h>
int main()
{
char a[100000];
int i=0;
gets(a);
for(i=0;i<strlen(a);++i){
char *pos = strchr(a,a[i]);
pos = strchr(pos+1,a[i]);
if(pos == NULL ){
printf("%c\n",a[i]);
break;
}
}
if(i == strlen(a))
printf("no\n");
return 0;
}
第二题
#include<stdio.h>
int main()
{
char a[30],*pos;
char s,r;
int i=0;
scanf("%s %c %c",a,&s,&r);
pos = &a[0];
while(pos != NULL){
pos = strchr(pos,s);
if(pos == NULL) break;
*pos = r;
++pos;
}
printf("%s\n",a);
return 0;
}
有帮助麻烦您采纳一下