当前位置:网站首页>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);
}
}
边栏推荐
- 愉悦资本新双币基金近40亿元完成首次关账
- C library function - qsort()
- 中国PETG市场预测及战略研究报告(2022版)
- 全局事件总线
- Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
- JS first summary
- fpga阻塞赋值和非阻塞赋值
- [acnoi2022] guess numbers
- Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
- Exercise 9-3 plane vector addition
猜你喜欢
玖逸云黑免费无加密版本源码
Programmable logic device software testing
Uio-66-cooh loaded bendamostine | hydroxyapatite (HA) coated MIL-53 (FE) nanoparticles | baicalin loaded manganese based metal organic skeleton material
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
常见问题之PHP——ldap_add(): Add: Undefined attribute type in
JVM class loading
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
Redis:字符串類型數據的操作命令
随机推荐
Exercise 10-1 judge the three digits that meet the conditions
QT learning 17 dialog box and its types
JS get DPI, PX to cm, cm to PX
QT learning 24 layout manager (III)
Exercise 8-7 string sorting
Too many files with unapproved license
SSH访问控制,多次失败登录即封掉IP,防止暴力破解
Exercise 8-2 calculate the sum and difference of two numbers
JS shift operators (< <,> > and > > >)
npm install卡住与node-npy的各种奇怪报错
愉悦资本新双币基金近40亿元完成首次关账
QT learning 20 standard dialog box in QT (middle)
Redis:Redis的数据结构、key的操作命令
Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions
Facebook 如何将 Instagram 从 AWS 搬到自己的服务器
Toast UI editor (editor allows you to edit your markup document using text or WYSIWYG, with syntax highlighting, scrolling synchronization, real-time preview and chart functions.)
7-18 finding the single root of polynomial by dichotomy
7-16 find the set of integers that meet the given conditions
How to delete an attribute or method of an object
jvm-类加载