当前位置:网站首页>Find specified characters
Find specified characters
2022-07-03 14:15:00 【Study hard 867】
This question requires the preparation of procedures , Find a specified character from a given string .
Input format :
The first line of input is a character to be found . The second line is a non empty string ending with carriage return ( No more than 80 Characters ).
Output format :
If you find , In one line, according to the format “index = Subscript ” Output the maximum subscript of the character in the string ( Subscript from 0 Start ); Otherwise output "Not Found".
sample input 1:
m
programming
sample output 1:
index = 7
sample input 2:
a
1234
sample output 2:
Not FoundCode :
#include <stdio.h>
int main(){
int i,flag;
char x;
int g;
char a[80];
scanf("%c",&x);
getchar();
for(i=0;(a[i]=getchar())!='\n';i++);
a[i]='\0';
flag=0;
for(i=0;a[i]!='\0';i++){
if(x==a[i]){
flag=1;
g=i;
}
}
if(flag==0)printf("Not Found");
else{
printf("index = %d",g);
}
}边栏推荐
- Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
- Exercise 10-1 judge the three digits that meet the conditions
- 剑指 Offer 28. 对称的二叉树
- 7-9 find a small ball with a balance
- 别再问自己适不适合做软件测试了
- Redis: commandes d'action pour les données de type chaîne
- protobuf与grpc
- concat和concat_ws()区别及group_concat()和repeat()函数的使用
- Redis: redis data structure and key operation commands
- Print. JS -- web page file printing
猜你喜欢

Mysql多表查询 #子查询
![[clean up the extraordinary image of Disk C]](/img/0d/331115bc5d82d6337ae975a08494b2.jpg)
[clean up the extraordinary image of Disk C]

八大排序

Exercise 9-1 time conversion

Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not

QT learning 24 layout manager (III)

FPGA test method takes mentor tool as an example

28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;

信创产业现状、分析与预测

Generate directories from web content
随机推荐
JS Part III
JS matrix zero
Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
jvm-运行时数据区
Solution to failure or slow downloading of electron when electron uses electron builder to package
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
Eight sorts
How to delete an attribute or method of an object
Current situation, analysis and prediction of information and innovation industry
FPGA test method takes mentor tool as an example
protobuf与grpc
simpleParallax. JS (create poor visual effects for website pictures)
全文检索引擎Solr系列—–全文检索基本原理
Leetcode(4)——寻找两个正序数组的中位数
Global event bus
Redis:Redis的数据结构、key的操作命令
npm install卡住与node-npy的各种奇怪报错
MongoDB数据库入门的常用命令
PCB中常用快捷键
愉悦资本新双币基金近40亿元完成首次关账