C#通过linq对数组进行筛选排序using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace OrderQueryResults{ class Program { static void……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2944浏览 2002个赞
C#通过linq语句查询数组中以特定字符开头的元素下面的代码查询数组中以字母k开头的元素using System;using System.Collections.Generic;using System.Linq;using System.Text; static void Main(string[] args){ string[……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3062浏览 226个赞
C#中保存Session的三种方法及Web.Config设置 保存session到sql server,需要指定Sql Server服务器,这种方法因为要读写数据库最慢<sessionStatemode="SQLServer&q……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2218浏览 2117个赞
C#中抛出异常的方法,C#中可以通过throw抛出一个指定的异常private void DoProcess(string value){ if (string.IsNullOrEmpty(value)) { throw new ArgumentNullException("value","……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3279浏览 2140个赞
C#堆排序代码private static void Adjust (int[] list, int i, int m){ int Temp = list[i]; int j = i * 2 + 1; while (j <= m) { //more children if(j &……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2812浏览 2777个赞
C#快速排序代码演示private static int Partition (int[] list, int i, int j){ int Key = list [i]; while (i < j) { //j to the left scan while (list [j] >……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3117浏览 2548个赞
C#折半插入排序算法演示public static void BinarySort (int[] list){ for (int i = 1; i < list.Length; i+ +) { int low = 0; int high = i - 1; int Temp = lis……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2350浏览 1958个赞
C#插入法排序算法代码public static void InsertSort (int[] list){ for (int i = 1; i < list.Length; i++) { int Temp = list [i]; int j = i - 1; while (j &g……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2552浏览 485个赞
C#冒泡法排序代码public static void BubbleSort (int[] list){ for (int i = 0; i < list.Length; i++) { for (int j = 0; j < list.Length - i - 1; j++) { ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1488浏览 282个赞
C#选择法排序代码演示public static void SelectSort (int[] list){ for (int i = 0; i < list.Length; i++) { int min = i; for (int j = i + 1; j < list.Length……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1897浏览 592个赞
C#通过Socket在网络间发送和接收图片的演示代码 using System;using System.Collections.Generic;using System.Text;using System.Net.Sockets;using System.Net;using System.IO; namespace ConsoleApp……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2274浏览 1618个赞
C#通过Socket实现客户端和服务器端通信的简单例子下面的代码演示了如果创建一个用于在客户端和服务端交换信息的代码 Socket Server 服务器端using System;using System.Collections.Generi……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1360浏览 1868个赞
通常,我们创建一个数组后就不能调整其长度,但是Array类提供了一个静态方法CreateInstance用来创建一个动态数组,所以我们可以通过它来动态调整数组的长度。namespace ArrayManipulation{ Class Program { static void Main (String[] args)……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1857浏览 2173个赞
单件模式是一种设计模式,即保持同时只能创建一个实例,下面列出了C#实现单件模式的三种方法 方法1public sealed Class Singleton{ private static ReadOnly Singleton instance = new Singleto……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3139浏览 2919个赞
C#定义的一个MP3播放类,将Mp3文件作为资源文件包含到项目中,就可以播放mp3了using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1305浏览 2948个赞
C#中通过xpath查找xml的指定元素 orders.xml文档内容如下<?xml version="1.0"?><Order id="2004-01-30.195496"> <Client id=&qu……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1350浏览 2016个赞
C#列出当前系统所有正在运行的程序Using System.Diagnostics; foreach (Process p in Process.GetProcesses (System.Environment.MachineName)){ if (p.MainWindowHandle! = IntPtr.Zero) { ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1926浏览 365个赞
C#从数据库读取数据到DataSet并保存到xml文件,DataSet有一个WriteXml方法可以直接将数据保存到xml文件using System;using System.Data;using System.Xml;using System.Data.SqlClient;using System.IO; public class Tes……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2155浏览 390个赞
C#调用执行外部程序,如调用notepadclass Test { static void Main (string [] args) { System.Diagnostics.Process.Start ("notepad.exe"); } }……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2574浏览 350个赞
下面的代码通过Timer定时器每隔1000毫秒(1秒)触发一次事件,using System;using System.Timers; class TestTimer{ public static void Main () { Timer timer = new Timer(); timer.Ela……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2801浏览 1062个赞
C#中的list可以当做数组使用,而且无需定义长度,完全是动态的class Person{ public string Name { get; set; } public string Address { get; set; }} static void Main(string[] args){ List<Pers……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1482浏览 760个赞
C#代码发送简单的HTTP请求using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;namespace WRApp{class Program{static v……继续阅读 » 水墨上仙 4年前 (2021-03-12) 2905浏览 1944个赞
C#将布尔类型转换成字节数组byte[] b = null;b = BitConverter.GetBytes(true);Console.WriteLine(BitConverter.ToString(b));……继续阅读 » 水墨上仙 4年前 (2021-03-12) 3139浏览 1967个赞
C#将数字转换成字节数组,下面的代码用到了MemoryStream 和 BinaryWriter// Create a byte array from a decimalpublic static byte[] DecimalToByteArray (decimal src) { // Create a MemoryStream as a ……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1243浏览 2816个赞
C#将字节数组转换成数字// Create a decimal from a byte arraypublic static decimal ByteArrayToDecimal (byte[] src) { // Create a MemoryStream containing the byte array using (Memo……继续阅读 » 水墨上仙 4年前 (2021-03-12) 1750浏览 2530个赞
C++通过递归进行回文判断#include using namespace std; //将一整数逆序后放入一数组中(要求递归实现) int IsRound(char *str,int len) { if(*str==*(str+len-1)) return IsRound(str+1,len-2); if(le……继续阅读 » 水墨上仙 5年前 (2020-11-16) 1746浏览 1724个赞
创建游戏$ cocos new -p com.yt.supermario -d ~/yt/game/ -l cpp supermario> 拷贝模板到 /Users/yt/yt/game/supermario> 拷贝 cocos2d-x ...> 替换文件名中的工程名称,'HelloCpp' 替换为 &……继续阅读 » 开心洋葱 6年前 (2019-09-03) 2688浏览 0评论1796个赞
C语言多种方法求解字符串编辑距离问题编辑距离:通过插入、删除、替换一个字符(和交换相邻字符)的操作,使得字符串A和字符串B相同,而最少的操作次数就是编辑距离。如字符串abcd和aca的距离是2/* 递归搜索 */int calDistance1(char *ptrX, int xbeg, int xend, char *ptrY, int ybeg, i……继续阅读 » 水墨上仙 6年前 (2019-07-11) 2293浏览 2317个赞
coco vscode 调试错误,没有解决,有解决的朋友可以提供下ar: attachRequest: address: 192.168.1.104 port: 5086ar: attachRequest: connectedar: _termiated: cocos firefox protocol error: received error pac……继续阅读 » 开心洋葱 7年前 (2018-03-23) 3142浏览 0评论2576个赞
elasticsearch 运行报错解决 Exception in thread “main” Exception in thread "main" 2018-03-23 11:03:44,430 main ERROR No log4j2 configuration file found. Using de……继续阅读 » 开心洋葱 7年前 (2018-03-23) 2894浏览 16评论482个赞
v8::WasmCompiledModule::TransferrableModule::TransferrableModule(严重性 代码 说明 项目 文件 行 禁止显示状态错误 C2610 “v8::WasmCompiledModule::TransferrableModule::TransferrableModule(v8::WasmCompil……继续阅读 » 开心洋葱 7年前 (2018-03-22) 2032浏览 0评论1379个赞
使用cocos2dx 编译android游戏客户端时,使用android studio 3.0以上就会出现如下错误Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details……继续阅读 » 开心洋葱 7年前 (2018-03-22) 3008浏览 48评论1368个赞
Go语言官方带了一个工具叫cgo,可以很方便的在Go语言代码中内嵌C代码或做C和Go代码的集成。下面是一段简单的在Go中内嵌C的实验代码:package main/*#include #include void say_hello() { printf("Hello World!\n");}*/……继续阅读 » 水墨上仙 8年前 (2018-01-20) 1418浏览 2230个赞
//// main.c// test1//// Created by yt on 2017/.// Copyright © 2017年 yt. All rights reserved.//#include <stdio.h>#include <time.h>#include <stdlib.h>……继续阅读 » 开心洋葱 8年前 (2017-07-08) 3113浏览 0评论2205个赞
Temporary breakpoint 2 at 0x100000ef4: file sort_select.c, line 30.Starting program: /Users/yt/Documents/CodeProj/c/sort_select During startup program terminated with signal SIG1……继续阅读 » 开心洋葱 8年前 (2017-06-04) 1865浏览 0评论2008个赞
字符串编辑距离 这是一种字符串之间相似度计算的方法。 给定字符串S、T,将S转换T所需要的插入、删除、替代操作的数量叫做S到T的编辑路径。 其中最短的路径叫做编辑距离。 这里使用了一种动态规划的思想求编辑距离。package com.mycompany.project;/** * 字符串编辑距离 * * 这是一种字符串之间相似度计算的方法……继续阅读 » 水墨上仙 8年前 (2017-06-04) 2438浏览 2284个赞
二、编译警告:warning C4996 与 Security Enhancements in the CRT将过去的工程用VS2005打开的时候。你有可能会遇到一大堆的警告:warning C4996。比如:warning C4996: ‘strcpy’: This function or variable may be un……继续阅读 » 开心洋葱 8年前 (2017-06-02) 1519浏览 0评论312个赞
C语言回溯法解决背包问题#include #include #include using namespace std;#define MAXN 10struct Goods_Info{ int v; //价值 int w; //重量 double vw; //价值重量比}goods[MAXN];int n;……继续阅读 » 水墨上仙 8年前 (2017-05-31) 1954浏览 2121个赞
100 可以表示为带分数的形式:100 = 3 + 69258 / 714 还可以表示为:100 = 82 + 3546 / 197 注意特征:带分数中,数字1~9分别出现且只出现一次(不包含0)。 类似这样的带分数,100 有 11 种表示法。#include#include/*检查某个数是否出现重位的情况,可以与nKill整合,但这儿单独列出*……继续阅读 » 水墨上仙 8年前 (2017-05-31) 2579浏览 190个赞
0-1背包问题:给定n种物品和一背包.物品i的重量是wi, 其价值为ui,背包的容量为C. 问如何选择装入背包的物品,使得装入背包中物品的总价值最大? 分析: 0-1背包是子集合选取问题,一般情况下0-1背包是个NP问题. 第一步 确定解空间:装入哪几种物品 第二步 确定易于搜索的解空间结构: 可以用数组p,w分别表示各个物品价值和重量。 用数组x记录,是否……继续阅读 » 水墨上仙 8年前 (2017-05-31) 1988浏览 2831个赞
Input输入 输入设备(如按键,键盘,触摸屏,鼠标等)是典型的字符设备,其一般的工作机制是低层在按键,触摸等动作发生时产生一个中断(或驱动通过timer定时查询),然后cpu通过SPI,I2C或者外部存储器总线读取键值,坐标等数据,放一个缓冲区,字符设备驱动管理该缓冲区,而驱动的read()接口让用户可以读取键值,坐标等数据。 Linux 输入子……继续阅读 » 开心洋葱 8年前 (2017-05-29) 2342浏览 0评论2708个赞
堆栈计算逆波兰式使用C语言实现逆波兰式(Reverse Polish notation,RPN,或逆波兰记法),也叫后缀表达式(将运算符写在操作数之后)一个表达式E的后缀形式可以如下定义:(1)如果E是一个变量或常量,则E的后缀式是E本身。(2)如果E是E1 op E2形式的表达式,这里op是如何二元操作符,则E的后缀式为E1’E2……继续阅读 » 水墨上仙 8年前 (2017-04-20) 2464浏览 1168个赞
C/C++ 开源库及示例代码= == 说明 =本页面汇总俺收集的各种 C 和 C++ 的开源代码库,不定期更新。如果你发现本页面的开源库有错漏之处,非常欢迎给俺提供反馈——有 GitHub 帐号的同学,可以[https://github.com/programthink/opensource/issues 给俺发 issue];没帐号的同学,可以去[……继续阅读 » 开心洋葱 8年前 (2017-03-04) 1830浏览 0评论198个赞
vs2015的默认配置%USERPROFILE%\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props<?xml version="1.0" encoding="utf-8"?><Project Defaul……继续阅读 » 开心洋葱 8年前 (2017-02-21) 1545浏览 0评论2307个赞
安装完 VS2015 后,直接新建项目->win32控制台->运行,结果报错!”无法打开包括文件: “stdio.h”: No such file or directory””lnk1104:无法打开文件 ucrtd.lib ”奇了怪了,stdio.h 和 ucrtd.lib 都是 VS 自带的头文件和库文件,都无法识别,……继续阅读 » 开心洋葱 8年前 (2017-02-20) 1578浏览 0评论1605个赞