c++题目
多壹
这个作者很懒,什么都没留下…
展开
-
多线程实现 qq 群聊的服务端和客户端
效果比较简陋,但是功能可以实现效果:服务器#include <iostream>#include <winsock2.h>//必须写在windows.h前面#include <windows.h>#pragma comment(lib,"ws2_32.lib")#define MAX_CLI 256#define Max_Buf_Size 1024SOCKET cliSocket[MAX_CLI];int cliCount = 0;HANDLE原创 2021-03-11 02:31:04 · 296 阅读 · 0 评论 -
网络编程实战之网络文件截取---隐藏进程与修改注册表
客户端发给别人,只要打开一次就添加在系统启动项里,只要服务端打开每次都会获取文件,只是个简单的demo服务器端在这里插入代码片#include <iostream>#include <WinSock2.h>#pragma comment(lib,"ws2_32.lib")using namespace std;void ErrorHanding(const char* msg){ fputs(msg, stderr); fputc('\n', stderr);原创 2021-03-09 01:23:48 · 172 阅读 · 0 评论 -
类练习1
方法1:用动态分配内存实现#include <iostream>class hString{private: char* string; unsigned short len; unsigned short length(const char* str) { unsigned short len = 0; while (str[len]) { len++; } return len; }public: hString() { len = .原创 2021-01-04 21:03:15 · 176 阅读 · 0 评论 -
控制台打开c++程序并且模拟注册程序,并打印,无string,char模拟string函数处理字符串
#include <iostream>#include <string>struct ZhanghaoInfo{ char* id; char* pass; char* country;};bool Help(const char* str) { if (str == "/?") { std::cout << "123"; return true; } return false;}int GetIndex(const char.原创 2020-12-01 17:32:27 · 88 阅读 · 0 评论 -
string求出长度(含中文,中文算1个长度)
#include <iostream>#include <string>int main(){ std::string str; std::cin >> str; int count{ 0 }; for (int i = 0; str.length(); i++) { if (str[i] < 0 || str[i]>127) { count++; i++; } } std::cout << count;原创 2020-11-21 16:07:07 · 939 阅读 · 0 评论 -
c++加减乘除计算器
#include <iostream>#include <conio.h>#include <string>void main(){ char str[0xFF]; do { system("cls"); float a{}; float b{}; int count = 1; int isOperating = -1; bool isFirst = true; std::string text{ "按任意键重置,继续计算\n"原创 2020-11-13 15:58:21 · 1919 阅读 · 0 评论 -
char[]字符数组(字符串)求出数组长度(含中文,中文算1个长度)
#include <iostream>int main(){ char str[0xFF]; std::cin >> str; int i{ 0 }; int count{ 0 }; while (str[i] != '\0') { if (str[i] <0||str[i]>127) { i++; } i++; count++; } std::cout << count;}思路:因为在中文编码中大于127原创 2020-11-12 09:28:32 · 2394 阅读 · 0 评论 -
输入一串字符串,判断里面有多少大写字母,小写字母,数字,空格和特殊字符
#include <iostream>#include <string>void main() { std::string str; std::cout << "请输入一段字符串"; getline(std::cin,str); int lower = 0; int upper = 0; int number = 0; int space = 0; int other = 0; for (int i =0;i < str.length();原创 2020-11-05 11:18:18 · 4456 阅读 · 0 评论 -
不用第三个变量,交换两个变量值(位运算)
#include <iostream>void main() { int a, b; std::cout << "a="; std::cin >> a; std::cout << "b="; std::cin >> b; a = a ^ b; b = a ^ b; a = a ^ b; std::cout << "a=" << a << "\n" << "b=" <<原创 2020-11-04 21:43:46 · 243 阅读 · 0 评论 -
c++技能系统练习(指针和new)
#include <iostream>#include <string>#include <iomanip>struct JiNeng{ std::string Name; int NeedMP; int NeedSP; int ACT; int ACTB;};struct UsSkill { JiNeng* jineng; int LV; int Cold; bool IsUse;};struct Players{ std..原创 2020-11-03 11:16:46 · 188 阅读 · 0 评论 -
c++数组排序插入
**解题1:****std::vector**#include <iostream>#include <vector>int main(){ std::vector<int> a {1, 3, 14, 25, 31, 32, 58, 73, 98, 105}; int x{}; std::cin >> x; int* pa = &a[0]; for (int i = 0; i < 11; i++) { if (.原创 2020-10-17 12:08:13 · 346 阅读 · 0 评论