当前位置:网站首页>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);
}
}
边栏推荐
- Data governance: data quality
- Redis list detailed explanation of character types yyds dry goods inventory
- Luogu p4127 [ahoi2009] similar distribution problem solution
- Go learning notes (3) basic types and statements (2)
- TS 体操 &(交叉运算) 和 接口的继承的区别
- Database addition, deletion, modification and query
- Uibehavior, a comprehensive exploration of ugui source code
- Entity class design for calculating age based on birthday
- Sanzi chess (C language)
- edge浏览器 路径获得
猜你喜欢
Understanding of law of large numbers and central limit theorem
Sanzi chess (C language)
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
Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data
Key value judgment in the cycle of TS type gymnastics, as keyword use
2.10transfrom attribute
Wireshark grabs packets to understand its word TCP segment
07- [istio] istio destinationrule (purpose rule)
Asia Pacific Financial Media | art cube of "designer universe": Guangzhou community designers achieve "great improvement" in urban quality | observation of stable strategy industry fund
Risk planning and identification of Oracle project management system
随机推荐
Machine learning - decision tree
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
File upload of DVWA range
opencv学习笔记九--背景建模+光流估计
Pre knowledge reserve of TS type gymnastics to become an excellent TS gymnastics master
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
2.10transfrom attribute
[redis] Introduction to NoSQL database and redis
C # display the list control, select the file to obtain the file path and filter the file extension, and RichTextBox displays the data
解决方案:智慧工地智能巡检方案视频监控系统
How to estimate the number of threads
MySQL view tablespace and create table statements
Uibehavior, a comprehensive exploration of ugui source code
Learn Arduino with examples
Data governance: misunderstanding sorting
Understanding of law of large numbers and central limit theorem
Linked list interview questions (Graphic explanation)
Simulation of Teman green interferometer based on MATLAB
"Friendship and righteousness" of the center for national economy and information technology: China's friendship wine - the "unparalleled loyalty and righteousness" of the solidarity group released th
合规、高效,加快药企数字化转型,全新打造药企文档资源中心