11: Successive occurrences of the character (1.9)

Source: Internet
Author: User

The title does not describe what the character is, but the ASCII code is 0~255 and can be directly defined by an array of a[1000].

How do I record the number of consecutive occurrences of a character?

Character scan, define a variable record with an initial value of 1

#include <cstdio>#include<cstring>Chars[1100];inta[1100]={0};intMain () {intk,num=1; scanf ("%d",&k); scanf ("%s", s); intlen=strlen (s);  for(intI=0; i<=len-2; i++){        if(s[i]==s[i+1]) num++; Elsenum=1; if(num>=k) {printf ("%c\n", S[i]); return 0; }} printf ("no\n"); return 0;}
View Code

11: Successive occurrences of the character (1.9)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.