char函数

11/2 下午 <String>

╄→尐↘猪︶ㄣ 提交于 2019-12-03 07:27:08
344. Reverse String 解法一(暴力法): 直接从两头往中间走,同时交换两边的字符即可 首位对调位置。 class Solution { public void reverseString(char[] s) { int tail = s.length-1; for(int i = 0; i < s.length/2; i++){ char temp = s[i]; s[i] = s[tail-i]; s[tail-i] = temp; } } } 解法二: 利用swap函数求解 class Solution { public void reverseString(char[] s) { // if(s == null || s.length == 0) // return ""; int left = 0, right = s.length-1; while(left < right){ char temp = s[left]; s[left++] = s[right]; s[right--] = temp; } } } 151. Reverse Words in a String 1.反转全部字符数组 2.反转每个单词 3.清楚多余空格 class Solution { public String reverseWords(String s) { int n =

C 错误

随声附和 提交于 2019-12-03 07:18:20
*) scanf()函数里面只能形如 scanf("%s %d",symbel,&count); ,不能够是 scanf("提示文本%s %d",symbel,&count); ,不能够带有文本 *) char symbel;#这样是不能接受输入的, printf("please enter:"); scanf("%c",symbel); char symbel[10];//这样可以 scanf("%c",symbel);这样只会接受一个字符,要改为”%s" printf("%s",symbel);但是要改为%s *) i++ 执行后i的结果会增加一,相当于i=i+1 值是会改变的 来源: https://www.cnblogs.com/Gaoqiking/p/11782676.html

C++ STL——异常

偶尔善良 提交于 2019-12-03 07:05:36
目录 一 C++异常机制概述 二 栈解旋(unwinding) 三 异常接口的声明 四 异常类型和异常变量的生命周期 五 C++标准异常库 六 异常的继承 注:原创不易,转载请务必注明原作者和出处,感谢支持! 注:内容来自某培训课程,不一定完全正确! 一 C++异常机制概述 什么是异常处理?一句话,异常处理就是处理程序中的错误。 为什么需要异常处理以及异常处理的基本思想? C++之父Bjarne Stroustrup在《The C++ Programming Language》中讲到:一个库的作者可以检测出发生了运行时错误,但一般不知道怎样去处理它们(因为和用户具体的应用有关);另一方面,库的用户知道怎样处理这些错误,但却无法检查它们何时发生(如果能检测,就可以在用户的代码里处理了,不用留给库去发现)。 Bjane Stroustrup说:提供异常的基本目的就是为了处理上面的问题。基本思想是:让一个函数在发现了自己无法处理的错误时抛出(throw)一个异常,然后它的(直接或间接)调用者能够处理这个问题。也就是说,C++将问题的检测与问题的处理相分离。 在异常处理机制出现之前的错误处理方式?在C语言中,对错误的处理总是围绕着两种方法:一是使用整型的返回值标识错误;二是使用errno宏(可以简单理解为一个全局整型变量)去记录错误。当然C++中仍然可以使用这两种方法

MD5 AND JSON AND XML

房东的猫 提交于 2019-12-03 06:28:09
MD5JSON.h #pragma once #include "include/json/json.h" #include "include/md5/md5.h" #include "xml/tinyxml/tinystr.h" #include "xml/tinyxml/tinyxml.h" #include <string> using namespace std; #pragma comment(lib,"md5_JSON\\include\\bin\\json_vc71_libmtd.lib") #define MJ MD5JSON::getInstance() #define JSON Json #define XM XML::getInstance() // //多线程调试 (/MTd) class MD5JSON { //md5 md5_state_t m_context; unsigned char m_Digest[16]; char m_outstr[256]; //json char *buf; Json::Reader reader; Json::Value root; string m_jsonfilename; Json::Value jsonItem; public: ///////////////////////// MD5 static

cocos2D-X 常用功能封装

帅比萌擦擦* 提交于 2019-12-03 06:27:55
Packaging_Kernel.h #pragma once #include <string> #include <map> #include <vector> #include "cocos2d.h" #include "ui\CocosGUI.h" #include "SimpleAudioEngine.h" #include "cocostudio\CocoStudio.h" #include "cocos\editor-support\spine\SkeletonAnimation.h" #include "cocos\platform\desktop\CCGLViewImpl-desktop.h" #include "cocos\math\CCGeometry.h" #include "cocos\editor-support\spine\extension.h" #include "cocos\math\Vec2.h" #include "cocos2d/extensions/GUI/CCScrollView/CCTableView.h" #include <iostream> #include <windows.h> #include <tchar.h> using namespace std; using namespace cocos2d; using

JSON 单例类

安稳与你 提交于 2019-12-03 06:27:16
MD5JSON.h #pragma once #include "include/json/json.h" #include "include/md5/md5.h" #include "xml/tinyxml/tinystr.h" #include "xml/tinyxml/tinyxml.h" #include <string> using namespace std; #pragma comment(lib,"md5_JSON\\include\\bin\\json_vc71_libmtd.lib") #define MJ MD5JSON::getInstance() #define JSON Json #define XM XML::getInstance() // //多线程调试 (/MTd) class MD5JSON { //md5 md5_state_t m_context; unsigned char m_Digest[16]; char m_outstr[256]; //json char *buf; Json::Reader reader; Json::Value root; string m_jsonfilename; Json::Value jsonItem; public: ///////////////////////// MD5 static

xml 单例类

旧城冷巷雨未停 提交于 2019-12-03 06:27:11
MD5JSON.h #pragma once #include "include/json/json.h" #include "include/md5/md5.h" #include "xml/tinyxml/tinystr.h" #include "xml/tinyxml/tinyxml.h" #include <string> using namespace std; #pragma comment(lib,"md5_JSON\\include\\bin\\json_vc71_libmtd.lib") #define MJ MD5JSON::getInstance() #define JSON Json #define XM XML::getInstance() // //多线程调试 (/MTd) class MD5JSON { //md5 md5_state_t m_context; unsigned char m_Digest[16]; char m_outstr[256]; //json char *buf; Json::Reader reader; Json::Value root; string m_jsonfilename; Json::Value jsonItem; public: ///////////////////////// MD5 static

DDOS 单例

百般思念 提交于 2019-12-03 06:26:52
DDOS.H #pragma once //g++ ../../../Main.cpp ../../../DDOS.cpp -lpthread #include <stdio.h> #include <ctype.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> #include <string.h> #include <netdb.h> #include <errno.h> #include <stdlib.h> #include <time.h> #include <arpa/inet.h> #include <pthread.h> // -lpthread // ./a.out www.baidu.com 80 struct ip { unsigned char hl; unsigned char tos; unsigned short total_len; unsigned short id; unsigned short frag_and_flags; unsigned char ttl; unsigned char proto; unsigned short

C++ 杂项

谁说胖子不能爱 提交于 2019-12-03 06:21:28
#include <iostream> #define Main main #define COLOR_GREEN system("color 2"); #include <vector> #include <list> #include <WinSock2.h> #include <WS2tcpip.h> #include <LM.h> #include <winnetwk.h> #include "BitMap.h" #include <wlanapi.h> #include "ATBAudioEngine/ATBAudioEngine.h" #pragma comment(lib,"Ws2_32.lib") #pragma comment(lib,"Mpr.lib") #pragma comment(lib,"netapi32.lib") #pragma comment(lib,"Wlanapi.lib") #include <Windows.h> class disorderly { int m_buf[10] = { 0 }; public: void initBuf() { srand(GetTickCount()); int len = sizeof(m_buf) / sizeof(int); for (int i = 0; i < len; i++) { m_buf

C语言qsort函数总结

一个人想着一个人 提交于 2019-12-03 05:25:08
   前几天在leetcode上刷题,用qsort对二维数组进行排序,发现不会写qsort的比较函数。后面在网上找了几篇博客才弄明白,趁今天有空,对这个做一下总结,主要是以下4个方面: 1、qsort总体介绍 2、qsort应用于一维数组 3、qsort应用于指针数组 4、qsort应用于二维数组 1、qsort总体介绍   函数声明:void qsort(void *base, size_t nitems, size_t size, int (*compare)(const void *, const void*))   参数解释:     base-- 指向要排序的 数组 的第一个元素的指针。注意这里说是数组,所以必须是对连续的内存块进行排序。     nitems-- 由 base 指向的数组中元素的个数     size-- 数组中每个元素的大小,以字节为单位     compare-- 用来比较两个元素的函数。这是qsort最难的一部分了。这里主要要注意以下2点:1、在写compare函数时,你的两个形参必须是const void *型,但是在compare函数内部你又必须将const void *类型的形参转换为实际的类型。这是我最当时最难以理解的一个问题了:我需要转换成什么类型。看了别人的总结才知道,是: 指向数组元素的指针,指向数组元素的指针,指向数组元素的指针