当前位置:网站首页>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 Found
Code :
#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);
}
}
边栏推荐
- Zabbix添加Calculated items后保存页面成空白
- Exercise 10-8 recursive implementation of sequential output of integers
- LNMP环境mail函数不能发送邮件解决
- Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
- Message subscription and publishing
- Raft 协议
- 编程语言:类型系统的本质
- jvm-类加载
- simpleParallax. JS (create poor visual effects for website pictures)
- 7-24 reduction of the simplest fraction (rolling Division)
猜你喜欢
JS first summary
Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)
Exercise 6-6 use a function to output an integer in reverse order
[email protected] (FE) | glycyrrhetinic acid modified metal organ"/>
Formation of mil-100 (FE) coated small molecule aspirin [email protected] (FE) | glycyrrhetinic acid modified metal organ
愉悦资本新双币基金近40亿元完成首次关账
Exercise 6-1 classify and count the number of characters
Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
Exercise 9-3 plane vector addition
[clean up the extraordinary image of Disk C]
随机推荐
必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
Page generation QR code
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(
npm install卡住与node-npy的各种奇怪报错
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
Exercise 10-1 judge the three digits that meet the conditions
关于回溯问题中的排列问题的思考(LeetCode46题与47题)
Vite project commissioning
Collection of mobile adaptation related articles
Simulated access
Current situation, analysis and prediction of information and innovation industry
JS download files through URL links
Mysql多表查询 #子查询
7-7 12-24 hour system
6-9 statistics of single digits (15 points)
simpleParallax. JS (create poor visual effects for website pictures)
7-15 calculation of PI
Too many files with unapproved license
Jiuyi cloud black free encryption free version source code
Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)