zoukankan      html  css  js  c++  java
  • 字符串-01. 在字符串中查找指定字符(15)

    输入一个字符串S,再输入一个字符c,要求在字符串S中查找字符c。如果找不到则输出“Not found”;若找到则输出字符串S中从c开始的所有字符。

    输入格式:

    输入在第1行中给出一个不超过80个字符长度的、以回车结束的非空字符串;在第2行中给出一个字符。

    输出格式:

    在一行中按照题目要求输出结果。

    输入样例1:

    It is a black box
    b
    

    输出样例1:

    black box
    

    输入样例2:

    It is a black box
    B
    

    输出样例2:

    Not found

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <math.h>
     4 #include <string.h>
     5 #include <stdlib.h>
     6 
     7 using namespace::std; 
     8 
     9 int main(){
    10   
    11       char a[90];
    12       char b;
    13       gets(a);
    14      
    15       scanf("%c",&b);
    16       int i=0;
    17       int flag=0;
    18       while(a[i]!='')
    19       {
    20           if(a[i]==b)
    21           {
    22               flag=1;
    23           }
    24           if(flag==1)
    25           {
    26               printf("%c",a[i]);
    27           }
    28           i++;
    29       }
    30       if(flag==0)
    31       {
    32           printf("Not found");
    33       }
    34       return 0;
    35 }
  • 相关阅读:
    004 连接查询
    003 常用函数说明
    003 限定查询
    002 基础查询
    001 基础数据表脚本
    001 redis的简介和重点
    006 表单组件
    005 基本表单
    004 表格元素
    谚语,
  • 原文地址:https://www.cnblogs.com/ligen/p/4279544.html
Copyright © 2011-2022 走看看