Android parsing json fastest library: Json-smart

Source: Internet
Author: User

"Disclaimer: This article is limited to self-summary and mutual exchange, there are flaws also hope you point out." Contact e-mail: [Email protected] "

Title: finds the first occurrence of a character in a string. If you enter Abaccdeff, then output B.

Topic Analysis:

One, no complexity requirements

Second, the sequential traversal of the string, and then each traversal of the resulting character, in the entire string lookup (note: To filter out the index of the current character)

Algorithm implementation:

#include <stdio.h> #include <string.h>/*** find @c in @str, it filters out the characters */char *str_chr (const char *STR, char C, int num) {int len = strlen (str), char *re = Str;int i=0; for (; i<len; i++) {if (i = = num) {re++;continue;} if (*re = = c) return re;re++;} return NULL;}  Char find_once_char_in_str (const char *str) {int I=0;int len = strlen (str); for (; i<len; ++i) {if (STR_CHR (str, str[i], i) = = NULL) return str[i];} return 0;} int main () {char *str = "aabadccdebff7e";p rintf ("--->%c\n", Find_once_char_in_str (str)); return 0;}


Related Article

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.