题目描述计算字符串最后一个单词的长度,单词以空格隔开。输入描述:一行字符串,非空,长度小于5000。输出描述:整数N,最后一个单词的长度。解法(C语言版):#include<stdio.h>#include<string.h>intmain(){charstr[5000];inti,n,len;gets(str);len=strlen(str);n=0;if(len!=0)
分类:
其他好文 时间:
2020-01-16 10:31:33
阅读次数:
77
https://pintia.cn/problem-sets/12/problems/342 1 bool palindrome(char *s) 2 { 3 int n, i, k; 4 bool ret; 5 6 n = strlen(s); 7 i = 0; 8 k = n - 1; 9 wh ...
分类:
其他好文 时间:
2020-01-14 20:59:58
阅读次数:
89
1、#include<iostream> 运算符 sizeof 功能:计算可见字符串包括 '\0’的s的长度 sizeof是C/C++中的一个操作符(operator),简单的说其作用就是返回一个对象或者类型所占的内存字节数 2、strlen是一个函数 #include <string.h> int ...
分类:
其他好文 时间:
2020-01-05 15:17:08
阅读次数:
83
构造题好评~~,虽然这把崩了~~ "原题解" "A" 题意 二人游戏,一个人有 $k_1$ 张牌,另一个人 $k_2$ 张,满足 $2\le k_1+k_2=n\le 100$,每张牌上有一个数,保证所有的牌上的数互不相同且在 $[1,n]$ 内 每回合双方都会出一张牌,牌上数小的一方的牌会给牌上数 ...
分类:
其他好文 时间:
2020-01-03 23:24:33
阅读次数:
95
问题描述: c++ 中 char*/string 形式的字符串无法正确的对中文字符串进行处理(如 find, strlen, substr 等常规操作) 。 比如当你在char* 中 find 英文逗号时,有可能匹配的不只是逗号,还找到了某个汉字的一个字节,而你无法在char*中区分它们。 问题原因 ...
分类:
编程语言 时间:
2020-01-03 15:34:56
阅读次数:
190
class Solution { public: string gethead(string str){//获取头单词 string ret = ""; int strlen = str.length(); for(int i = 0; i < strlen; ++i){ if(str[i] == ...
分类:
其他好文 时间:
2020-01-02 22:36:52
阅读次数:
74
一:String类型 string是二进制安全的(图片视频序列化存储,取出来还是可以用的)最多512M get key (拿出来) set key(设key) append key value(在原来基础上增加) strlen key(长度) setnx key value(存在时候不设置成功1,不 ...
分类:
其他好文 时间:
2020-01-01 21:02:41
阅读次数:
70
1.isBlank()方法 1 public static boolean isBlank(String str) { 2 int strLen; 3 if (str == null || (strLen = str.length()) == 0) { //判断str是否为null或者str长度是否 ...
分类:
其他好文 时间:
2019-12-31 23:26:19
阅读次数:
89
服务端 其代码如下 #include <stdio.h> #include<stdlib.h> #include<sys/socket.h> #include<unistd.h> #define SERV_PORT 9898 #define SERV_IP "127.0.0.1" #include< ...
分类:
编程语言 时间:
2019-12-31 14:37:04
阅读次数:
88
自定义函数 实现字符串转数组 <?php $str = 'I want to go home '; strToArr( $str ); function strToArr( $str ) { $arr = []; $s = ''; for ( $i=0; $i < strlen( $str ); $ ...
分类:
编程语言 时间:
2019-12-30 21:39:12
阅读次数:
82