当前位置:网站首页>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);
}
}
边栏推荐
猜你喜欢
Message subscription and publishing
Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
Mysql多表查询 #子查询
Solution to failure or slow downloading of electron when electron uses electron builder to package
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
Current situation, analysis and prediction of information and innovation industry
QT learning 25 layout manager (4)
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
随机推荐
1px problem of mobile terminal
PCB中常用快捷键
[acnoi2022] guess numbers
Exercise 10-1 calculate the sum of 1 to n using recursive functions
7-2 and then what time (15 minutes)
Analysis of the characteristics of page owner
js . Find the first palindrome string in the array
Exercise 8-8 moving letters
Although not necessarily the best, it must be the hardest!
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
编程语言:类型系统的本质
常见问题之PHP——ldap_add(): Add: Undefined attribute type in
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
C language,%d% Difference between 2D%2d%02d
Selenium browser (1)
Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride(
Collection of mobile adaptation related articles
JS first summary
Leetcode(4)——寻找两个正序数组的中位数