C语言利用递归函数调用方式,将所输入的5个字符,以相反顺序打印出来#include "stdio.h"#include "conio.h"main(){ int i=5; void palin(int n); printf("\40:"); palin(i); pri……继续阅读 » 水墨上仙 5年前 (2021-03-20) 3012浏览 2923个赞
有5个人坐在一起,问第五个人多少岁?他说比第4个人大2岁。问第4个人岁数,他说比第3个人大2岁。问第三个人,又说比第2人大两岁。问第2个人,说比第一个人大两岁。最后问第一个人,他说是10岁。请问第五个人多大?程序分析:利用递归的方法,递归分为回推和递推两个阶段。要想知道第五个人岁数,需知道第四人的岁数,依次类推,推到第一人(10岁),再往回推。#inc……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2707浏览 1528个赞
一个5位数,判断它是不是回文数。即12321是回文数,个位与万位相同,十位与千位相同#include "stdio.h"#include "conio.h"main( ){ long ge,shi,qian,wan,x; scanf("%ld",&x); wan=x/……继续阅读 » 水墨上仙 5年前 (2021-03-20) 3056浏览 904个赞
vc.net中使用Qt连接SQLServer数据库//1.添加SQL库:"Qt project setting"-->"Qt Modules",在SQL library复选框前打勾.//2.添加头文件#include<QtSql>#include <QtSql/QSqlDatabas……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2228浏览 1606个赞
C++用回溯方法做全排列#include<cstring>#include<iostream>#define LEN 10using namespace std;char elem[LEN] = { 'a', 'b', 'c', 'd', &……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2380浏览 1173个赞
程序分析:用第一个与最后一个交换#include "stdio.h"#include "conio.h"#define N 5main(){ int a[N]={9,6,5,4,1},i,temp; printf("\n original array:\n"); for(i……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2000浏览 1822个赞
利用双重for循环控制输入二维数组,再将a[i][i]累加后输出。#include "stdio.h"#include "conio.h"/* 如果使用的是TC系列编译器则可能需要添加下句 */static void dummyfloat(float *x){ float y; dummyfloat(&am……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2549浏览 2287个赞
请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。程序分析:用情况语句比较好,如果第一个字母一样,则判断用情况语句或if语句判断第二个字母#include "stdio.h"#include "conio.h"void main(){ char letter; p……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1571浏览 1291个赞
C++ 实现矩阵相乘#include <iostream>using namespace std;void MatrixMultiplication(double *m1,double *m2,double *m3,int m,int n,int k){ for(int i=0;i<m;i++) { for(int j=……继续阅读 » 水墨上仙 5年前 (2021-03-20) 3307浏览 2123个赞
消息队列是一系列连续排列的消息,保存在内核中,通过消息队列的引用标识符来访问。消息队列与管道很相似,但使用消息队列的好处是对每个消息指定了特定消息类型,接收消息的进程可以请求接收下一条消息,也可以请求接收下一条特定类型的消息。来源:http://blog.csdn.net/muge0913/article/details/7342907#include……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1893浏览 2080个赞
使用动态内存时需要用户自己去申请资源和释放资源。用户可以随时的分配所需空间,根据需要分配空间大小,并在最后释放申请内存。动态内存也存在隐患:在大型的项目当中管理申请的动态内存是很复杂的,以及释放申请的内存有难想起的。在释放动态内存时可能不止一个指针指向了该内存,所以释放的时候是很容易出错的。内存无法释放就会造成内存泄露,这也就是为什么服务器要经常的每个一段时……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2184浏览 849个赞
Linux 实现了请求页面调度,页面调度是说页面从硬盘按需交换进来,当不再需要的时候交换出去。这样做允许系统中每个进程的虚拟地址空间和实际物理内存的总量再没有直接的联系,因为在硬盘上的交换空间能给进程一个物理内存几乎无限大的错觉。交换对进程来说是透明的,应用程序一般都不需要关心(甚至不需要知道)内核页面调度的行为。然而,在下面两种情况下,应用程序可能像影响系……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1523浏览 875个赞
如果我们把计算机上的操作系统及各种各样的软件看成一系列的有机生命,而不是指令集,那么这就是一个进程的世界,在进程的世界中同样有“道德”和“法制法规”,窥探进程世界,看它的侠肝义胆,风雨江湖路~~~~~linux支持多个进程同时进行,也就是我们常说的现代操作系统中的多道程序设计,所谓同时是linux系统调度各个进程分别占用cpu的时间。由于每个时间片的时间很……继续阅读 » 水墨上仙 5年前 (2021-03-20) 3248浏览 1491个赞
来源:http://blog.csdn.net/muge0913/article/details/7317452#include <sys/types.h>#include <stdio.h>#include <sys/wait.h>void check_exit(int status);main(){ ……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2815浏览 1413个赞
linux c 退出进程来源:http://blog.csdn.net/muge0913/article/details/7317580 linux中常用退出函数:#include<stdlib.h>voidexit(int status);intatexit(vo……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2952浏览 2252个赞
信号处理是linux程序的一个特色。用信号处理来模拟操作系统的中断功能。要想使用信号处理功能,你要做的就是填写一个信号处理函数即可。来源:http://blog.csdn.net/muge0913/article/details/7317621#include <stdio.h> #include <sys/types.h> ……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2718浏览 2568个赞
信号及其简介信号是一种进程通信的方法,他应用于异步事件的处理。信号的实现是一种软中断。它被发送为一个正在运行的进程,已告知进程某个事件发生了。来源:http://blog.csdn.net/muge0913/article/details/7322710 信号及其简介信号是一种进程通信……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2484浏览 1631个赞
C++ 查询硬件与系统配置的API函数 ActivateKeyboardLayout 激活一个新的键盘布局。键盘布局定义了按键在一种物理性键盘上的位置与含义Beep 用于生成简单的声音CharToOem 将一个字串从ANSI字符集转换到OEM字符集ClipCursor 将指针限制到指定区域ConvertDefaultLocale 将一个特殊的地……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2017浏览 2442个赞
要对一个信号进行处理,就需要给出此信号发生时系统所调用的处理函数。可以对一个特定的信号(除去SIGKILL和SIGSTOP信号)注册相应的处理函数。注册某个信号的处理函数后,当进程接收到此信号时,无论进程处于何种状态,就会停下当前的任务去执行此信号的处理函数。来源:http://blog.csdn.net/muge0913/article/details/7……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2044浏览 1846个赞
1、有时候不希望在接到信号时就立即停止当前执行,去处理信号,同时也不希望忽略该信号,而是延时一段时间去调用信号处理函数。这种情况是通过阻塞信号实现的。2、信号阻塞和忽略信号的区别。阻塞的概念和忽略信号是不同的。操作系统在信号被进程解除阻塞之前不会讲信号传递出去,被阻塞的信号也不会影响进程的行为,信号只是暂时被阻止传递。当进程忽略一个信号时,信号会被传递出去……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2170浏览 2226个赞
int sigsuspend(const sigset_t *sigmask);此函数用于进程的挂起,sigmask指向一个信号集。当此函数被调用时,sigmask所指向的信号集中的信号将赋值给信号掩码。之后进程挂起。直到进程捕捉到信号,并调用处理函数返回时,函数sigsuspend返回。信号掩码恢复为信号调用前的值,同时将errno设为EINTR。进程结束……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2198浏览 189个赞
来源:http://www.daytimesoftware.com/blog/2007/10/suicidal-code-redux// Based on original code by Daniel Jakult, based on an idea from Brian Cooke.#ifdef BETA // 4 week expirati……继续阅读 » 水墨上仙 5年前 (2021-03-20) 3062浏览 2948个赞
点击提交按钮后显示loading,防止用户重复提交<style>#loading { position:absolute; width:500px; height:50px; top:50%; left:50%; margin: -25px -150px; background-color:#FFFFFF; bo……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1522浏览 1012个赞
根据unix时间戳返回一个相对当前时间的格式,如:3天前,24秒前等等//###############################//Usage:var myRelativeTime:String = timestampToRelative("Sun Oct 24 20:07:33 +0000 2010");//retu……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2132浏览 1573个赞
AS3实现的3D相册效果代码来源:http://www.adamcoulombe.info/lab/as3/screen-to-screen.htmlimport com.greensock.*;import com.greensock.easing.*;var lastRotX = 0;var lastRotY = 0; for(var i……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2956浏览 136个赞
创建Flash SharedObject(Flash Cookie)//create SOvar mySharedObject:SharedObject = SharedObject.getLocal("republicofcode");mySharedObject.data.firstName = "John&quo……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2715浏览 1801个赞
C++实现的简单hashtable(哈希表)范例//A simple example of hashtable#include <iostream>#include <cstdlib>#include <cstring>#include <iomanip>#define SIZE_KEY ……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1531浏览 190个赞
将NtStatus code转换成Win32 Error /* * This is an alternative to the RtlNtStatusToDosError() * function in ntdll.dll. It uses the GetOverlappedResult() * function in kernel32.dll……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1947浏览 1180个赞
C++生成标准的ASCII编码表/*The standard ASCII table defines 128 character codes (from 0 to 127), ofwhich, the first 32 are control codes (non-printable), and the remaining 96character……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1986浏览 355个赞
C++查看 IEEE 754 浮点数格式// A simple and practical way to show the format of the IEEE standardfor binary floating-point numbers (IEEE 754) is to use a union, as shown in the follow……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1552浏览 1727个赞
C++动态多维数组范例//creation of dynamic multidimensional arrays?#include <iostream>#include <iomanip>using namespace std; int main(){ //For creating one dimension……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2230浏览 2552个赞
一个简单的C语言链表实现/* Simple singly linked lists example usage; it is only one of many possible implementations - try your own enchancements.*/ #include <stdio.h>#in……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2904浏览 312个赞
C语言动态创建4维数组#include <stdio.h>#include <stdlib.h> /********************************************************//* ……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2914浏览 834个赞
本代码演示了如何使用千位分隔符“,”格式化数字输出//Example for using thousand separator (,) for decimal integer numbers#include <iostream>#include <cstdlib> using namespace std; int m……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1960浏览 270个赞
C++简单交换堆排序/* Can easily be modified to work with other data types */ void heapsort(int *arr, int n){ int start, end; // heapify the array for(start = (n - 2) / ……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2583浏览 722个赞
C++面向对象中的多态代码演示//An example of using overriding techniques to demonstrate function with a polymorphism behaviour. #include <iostream> using namespace std; // abstract……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2234浏览 647个赞
C语言初始化多维数组 //one dimensional array int x[5] = {1,2,3,4,5}; //two dimensional array int y[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}}; //Three dimens……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2750浏览 2455个赞
基于面向对象的C++双向链表代码演示//An example of a simple double linked list using OOP techniques#include <iostream>using namespace std; struct Node{ double value; Node *N,*P; ……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1979浏览 170个赞
几个非常有用的C字符串函数#include <string.h>#include <stdlib.h> void remchars(char *str, char c);void remcnks(char *str, char *cnk);void replchars(char *str, char c1, char ……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1981浏览 529个赞
C++异常处理范例代码// Program shows copying one text file from source location// to any other location (destination), plus possibility of changing its name, // and also shows many lan……继续阅读 » 水墨上仙 5年前 (2021-03-20) 3099浏览 1374个赞
C++使用key文件进行xor加解密/* The function (en/de)crypts an input data file with an input key file using the XOR method. The use of a key file instead of a plain text key m……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2084浏览 2067个赞
C++按单词换行的函数,按照指定的长度对字符串进行换行,如果指定的长度正好在某个单词中间,就往回查找,直到出现空格再换行/* This function takes a string and an output buffer and a desired width. It then copies the string to the buf……继续阅读 » 水墨上仙 5年前 (2021-03-20) 2328浏览 2552个赞
C++演示在不同的范围内不冲突使用同名变量的范例// An example of using the same variable declarations in different scopes in C++ without conflicts #include <iostream> using std::cout;using s……继续阅读 » 水墨上仙 5年前 (2021-03-20) 3143浏览 246个赞
C语言创建pascal三角图形//Procedural Programming technique shows creation of Pascal's Triangl#include <iostream>#include <iomanip>using namespace std;int** comb(int*……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1471浏览 1561个赞
AS3控制键盘的方向键代码package { import flash.display.MovieClip; import flash.events.Event; import flash.events.KeyboardEvent; public class KeyboardController extends MovieClip……继续阅读 » 水墨上仙 5年前 (2021-03-20) 1509浏览 687个赞