当前位置:网站首页>1202 character lookup
1202 character lookup
2022-07-06 07:58:00 【Zhanglilong 666】
Title Description
Find a specified character in a string , And output the number and position of the specified character in the string .
Input requirements
On the first line, enter a string , On the second line, enter the character you want to find .
Output requirements
The first line outputs the number of times the character has appeared in the string n, Back n Line outputs the place where the character once appeared ( The position of occurrence is calculated according to the daily habit from 1 Start marker )
sample input
maybeyesmaybleno m
sample output
2 1 9
#include<cstdio>
#include<cstring>
int main()
{
char a[1006],k;
int zll[1006]={0},len,i,sum=0,j=0;
gets(a);
len=strlen(a);
scanf("%c",&k);
for(i=0;i<len;i++){
if(a[i]==k){
sum++;
zll[j]=i;
j++;
}
}
printf("%d\n",sum);
for(i=0;i<j;i++){
printf("%d\n",zll[i]+1);
}
}
边栏推荐
- Notes on software development
- Type of data in energy dashboard
- Opencv learning notes 8 -- answer sheet recognition
- Artcube information of "designer universe": Guangzhou implements the community designer system to achieve "great improvement" of urban quality | national economic and Information Center
- Linked list interview questions (Graphic explanation)
- 【T31ZL智能视频应用处理器资料】
- Google可能在春节后回归中国市场。
- "Designer universe" APEC design +: the list of winners of the Paris Design Award in France was recently announced. The winners of "Changsha world center Damei mansion" were awarded by the national eco
- Uibehavior, a comprehensive exploration of ugui source code
- shu mei pai
猜你喜欢
Generator Foundation
It's hard to find a job when the industry is in recession
A Closer Look at How Fine-tuning Changes BERT
datax自检报错 /datax/plugin/reader/._drdsreader/plugin.json]不存在
Golang DNS 随便写写
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
链表面试题(图文详解)
21. Delete data
Asia Pacific Financial Media | designer universe | Guangdong responds to the opinions of the national development and Reform Commission. Primary school students incarnate as small community designers
A Closer Look at How Fine-tuning Changes BERT
随机推荐
【T31ZL智能视频应用处理器资料】
Helm install Minio
Leetcode question brushing record | 203_ Remove linked list elements
你想知道的ArrayList知识都在这
Generator Foundation
49. Sound card driven article collection
Le chemin du navigateur Edge obtient
Binary tree creation & traversal
Transformer principle and code elaboration
TS类型体操 之 字符串的妙用
[非线性控制理论]9_非线性控制理论串讲
Asia Pacific Financial Media | "APEC industry +" Western Silicon Valley invests 2trillion yuan in Chengdu Chongqing economic circle to catch up with Shanghai | stable strategy industry fund observatio
C intercept string
Epoll and IO multiplexing of redis
PHP - Common magic method (nanny level teaching)
实现精细化生产, MES、APS、ERP必不可少
octomap averageNodeColor函数说明
Data governance: data quality
Nft智能合约发行,盲盒,公开发售技术实战--合约篇
洛谷P4127 [AHOI2009]同类分布 题解