当前位置:网站首页>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);
}
}
边栏推荐
- wincc7.5下载安装教程(Win10系统)
- 【T31ZL智能视频应用处理器资料】
- 21. Delete data
- Simulation of holographic interferogram and phase reconstruction of Fourier transform based on MATLAB
- TS 体操 &(交叉运算) 和 接口的继承的区别
- 数据治理:主数据的3特征、4超越和3二八原则
- 23. Update data
- [Yugong series] February 2022 U3D full stack class 010 prefabricated parts
- Leetcode question brushing record | 203_ Remove linked list elements
- Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data
猜你喜欢
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
数字经济时代,如何保障安全?
成为优秀的TS体操高手 之 TS 类型体操前置知识储备
A Closer Look at How Fine-tuning Changes BERT
2.10transfrom attribute
【Redis】NoSQL数据库和redis简介
解决方案:智慧工地智能巡檢方案視頻監控系統
Esrally domestic installation and use pit avoidance Guide - the latest in the whole network
Google may return to the Chinese market after the Spring Festival.
Understanding of law of large numbers and central limit theorem
随机推荐
将 NFT 设置为 ENS 个人资料头像的分步指南
wincc7.5下载安装教程(Win10系统)
PHP Coding Standard
[count] [combined number] value series
数字经济时代,如何保障安全?
21. Delete data
octomap averageNodeColor函数说明
Data governance: Data Governance under microservice architecture
解决方案:智慧工地智能巡检方案视频监控系统
Opencv learning notes 9 -- background modeling + optical flow estimation
Epoll and IO multiplexing of redis
[非线性控制理论]9_非线性控制理论串讲
二叉树创建 & 遍历
Mex related learning
(lightoj - 1410) consistent verbs (thinking)
Opencv learning notes 8 -- answer sheet recognition
Data governance: 3 characteristics, 4 transcendence and 3 28 principles of master data
解决方案:智慧工地智能巡檢方案視頻監控系統
How to estimate the number of threads
Nft智能合约发行,盲盒,公开发售技术实战--拼图篇