C语言基础:for从大到小循环语句范例#include <stdio.h>int main () { int counter; for (counter = 5; counter >= 1; counter--) printf("%d ", counter); printf("……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2849浏览 2258个赞
C语言基础:for循环演示代码,字符循环和浮点数循环#include <stdio.h>int main () { char letter; float percent; for (letter = 'A'; letter <= 'Z'; letter++) pu……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2677浏览 729个赞
C语言基础:格式化输出带符号的数字#include <stdio.h>int main () { int int_value = 5; printf("Left justifed with sign %-+3d\n", int_value);return 1; } ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 3120浏览 1816个赞
C语言基础:goto语句用法演示#include <stdio.h>int main() { int count = 1; label: printf("%d ", count++); if (count <= 100) goto label;retu……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1548浏览 2033个赞
C语言基础:一个无限循环程序(死循环,不要运行)#include <stdio.h>int main () { int i; int result = 0; int value = 1; for (i = 0; i < 100; i++) { printf("%d "……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2364浏览 197个赞
C语言基础:格式化整数输出#include <stdio.h>int main () { int value = 5; printf ("%1d\n", value); printf ("%2d\n", value); printf ("%3d\n", ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2488浏览 589个赞
C语言基础:while语句使用范例#include <stdio.h>int main() { int counter = 1; // Initialize the control variable while (counter <= 100) // Test the control variable ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1659浏览 1737个赞
C语言基础:向左向右对其输出数字#include <stdio.h>int main () { int int_value = 5; float flt_value = 3.33; printf("Right justified %5d value\n", int_value); printf……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2589浏览 2914个赞
C语言基础:简单的数学运算#include <stdio.h>int main () { int seconds_in_an_hour; float average; seconds_in_an_hour = 60 * 60; average = (5 + 10 + 15 + 20) / 4; pr……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2180浏览 1007个赞
C语言基础:求模和取余演示#include <stdio.h>int main () { int remainder; int result; result = 10 / 3; remainder = 10 % 3; printf("10 Divided by 3 is %d Remainder ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1908浏览 597个赞
C语言基础:输出100以内的奇数和偶数#include <stdio.h>int main() { int counter; printf("\nEven values\n"); for (counter = 1; counter <= 100; counter++) { ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2785浏览 2908个赞
1. RSA说明RSA公钥加密算法是1977年由Ron Rivest、Adi Shamirh和LenAdleman在(美国麻省理工学院)开发的。RSA取名来自开发他们三者的名字。RSA算法基于一个十分简单的数论事实:将两个大素数相乘十分容易,但那时想要对其乘积进行因式分解却极其困难,因此可以将乘积公开作为加密密钥。2. RSA算法实现RSA算法是一种非对称密……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2940浏览 344个赞
C语言基础:将整数格式化成其它进制输出,如8进制,16进制#include <stdio.h>int main () { int value = 255; printf("The decimal value %d in octal is %o\n", value, value); p……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2022浏览 581个赞
C语言基础:自增自减符号位置的区别,– a和a–的区别演示#include <stdio.h>int main () { int value = 1; printf("Using postfix %d\n", value--); printf("Valu……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1903浏览 1257个赞
C语言基础:break语句使用范例代码#include <stdio.h>int main() { int counter; for (counter = 1; counter <= 100; counter++) { if (counter == 50) break; ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2952浏览 2481个赞
C语言基础:结构体及指针使用范例#include <stdio.h>#include <alloc.h>int main(void) { int i; struct ListEntry { int number; struct ListEntry *next; } start, *no……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2373浏览 2891个赞
C语言基础:常量的使用#include <stdio.h>#define ARRAY_SIZE 5int main(void) { int values[ARRAY_SIZE] = {80, 70, 90, 85, 80}; int i; for (i = 0; i < ARRAY_SIZE; i++) ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 3203浏览 2017个赞
C语言数组:数组初始化代码演示#include <stdio.h>int main(void) { int values[5] = {80, 70, 90, 85, 80}; int i; for (i = 0; i < 5; i++) printf("values[%d] %d\n"……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1843浏览 1670个赞
《C++ Primer》中说:在C++中没有多维数组,只有元素师数组的数组。如:要想创建一个二维整数数组,首先要创建一个一维动态数组,它由int *类型的指针构成。int*就是这个一维int指针数组的类型。// String.cpp : Defines the entry point for the console application.//#……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1968浏览 721个赞
C语言基础:输出变量的内存地址#include <stdio.h>int main(void) { int count = 1; float salary = 40000.0; long distance = 1234567L; printf("Address of count is %x\n"……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2615浏览 2660个赞
C语言基础:输出数组的内存地址#include <stdio.h>int main(void) { int count[10]; float salaries[5]; long distances[10]; printf("Address of the array count is %x\n"……继续阅读 » 水墨上仙 6年前 (2021-03-22) 3150浏览 1060个赞
C语言基础:获取数组的长度#include <stdio.h>int main(void) { int scores[100]; float salaries[100]; char string[100]; printf("Bytes used to hold int scores[100] is %d……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1941浏览 117个赞
C语言基础:两个获取数组地址的方法#include <stdio.h>int main(void) { int count[10]; float salaries[5]; long distances[10]; printf("Address of the array count is %x &……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2663浏览 1878个赞
C语言基础:数组作为函数参数调用代码演示#include <stdio.h>void show_array(int values[], int number_of_elements) { int i; for (i = 0; i < number_of_elements; i++) printf("%……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1779浏览 459个赞
C语言基础:数组作为函数参数传递演示代码#include <stdio.h>void show_array(int values[], int number_of_elements) { int i; printf("About to display %d values\n", number_of_ele……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2743浏览 2958个赞
C语言基础:二分查找法演示代码#include <stdio.h>int binary_search(int array[], int value, int size) { int found = 0; int high = size, low = 0, mid; mid = (high + low) / 2; ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2205浏览 815个赞
C语言基础:修改结构体数据#include <stdio.h>struct Shape { int type; int color; float radius; float area; float perimeter;};void change_structure(struct Shape *shape) { ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2710浏览 302个赞
反转单向链表分为递归和非递归两种方式。递归的实现方式比较简单,而非递归实现效率较高,在面试时应注意边界条件。 这道题在面试时被要求现场作答的概率还是很大的,比较tricky的地方就是要在当前条件下保存好next of next的指针,如果一时想不起来程序怎么写,可以先自己画个图看看。// ReverseList.cpp : Defines the en……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1517浏览 845个赞
C语言递归实现全排列来源:http://blog.csdn.net/creazyapple/article/details/7932432#include <stdio.h>int Swap(char *a,char *b){ char c; c = *a; *a = *b; *b = c;}/* ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1853浏览 299个赞
大家都知道,只有一个数时不用排序, 1.插入排序, 从第二个数开始,先将第二个数做一个副本放在一旁(变量中)。2.第二个数同前一个数比较,小于则用前一个数覆盖第二个数, 然后将副本放在前一个数前面3.再将第三个数做一个副本取出,第三个数同前一个数比较,小于则用前一个数覆盖第三个数(此时第二个数位置空闲), 然后用副本同前一个数的前一个数比较,如果小于,则用前……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1556浏览 1564个赞
C语言解决8皇后问题#include<iostream>using std::cout;using std::endl;#define my_abs(x) ((x)>=0?(x):(-(x)))const int n=8;void output(int a[],int n){static int count=1;cou……继续阅读 » 水墨上仙 6年前 (2021-03-22) 3365浏览 476个赞
C语言基础:数组元素访问 #include <stdio.h>int main(void) { int scores[5] = {80, 70, 90, 85, 80}; printf("Array Values\n"); printf("scores[0] %d\n", sco……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1611浏览 1673个赞
C语言数组:二位数组使用演示#include <stdio.h>void show_2d_array(int array[][10], int rows) { int i, j; for (i = 0; i < rows; i++) for (j = 0; j < 10; j++) pri……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1504浏览 1700个赞
C语言基础:结构体初始化#include <stdio.h>int main(void) { struct Shape { int type; int color; float radius; float area; float perimeter; } circle = {0, 1,……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2327浏览 225个赞
C语言基础:计算多维数组的大小#include <stdio.h>int main(void) { int box[3][3]; float year_sales[52][5]; char pages[40][60][20]; printf("Bytes to hold int box[3][3] %d……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2147浏览 742个赞
C语言基础:指针使用演示代码#include <stdio.h>int main(void) { int counter = 10; int *iptr; // Declare pointer value iptr = // Assign the address printf("……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2584浏览 1525个赞
C语言基础:通过指针遍历字符数组转换字符串为大写#include <stdio.h>#include <ctype.h>char *string_uppercase(char *string) { char *starting_address; starting_address = string; whi……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1438浏览 743个赞
c语言实现的通用二分查找算法作者:wallwind来源:http://blog.csdn.net/wallwind/article/details/8272141///* 二分查找是基于排好序的算法。复杂度低,并且很高效, 由于项目中大量使用的了二分查找,但是又不能每个业务实现一个 因此有必要实现一个通用的二分查找 其主要思想:通过对已经排好……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2413浏览 2142个赞
来源:……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2594浏览 2780个赞
C语言回溯法 0-1背包问题参数说明:c 背包容量n 物品数cw 当前背包重量cp 当前背包价值bestp 当前最优价值w[i] 表示物品i的重量p[i] 表示物品i的价值。Remind:数据处理前请将所有物品按照单位重量的价值排序,即p[i]/w[i]>=p[i+1]/w[i+1],i=1,2,..n-1。void Back……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2654浏览 918个赞
C语言判断字符串是否是 hex stringBOOL is_hex_string(char *str){ static unsigned int hex2bin[256]={0}; memset(hex2bin,0xFF,256); hex2bin['1'] = 1; hex2bin['2'] = 2;……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2094浏览 1923个赞
C语言编程返回数组的前n个元素之和#include<stdio.h>int sun(int *a,int n){/* int i,sum = 0; for(i = 0;i < n;i++) sum += a[i]; return sum;*/ static int sum = 0; if(n-- > 0) ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2810浏览 2317个赞
写一个函数比较两个字符串str1和str2的大小,若相等返回0,若str1大于str2返回1,若str1小于str2返回-1,不调用C++/C的字符串的字符库函数,请编写函数strcmp,函数定义为:intstrcmp(const char*src,const char*dst)来源:http://blog.csdn.net/sunmeng_alex/art……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2149浏览 865个赞
c语言版本的 动态数组创建 完整版来源: http://bugkill.01safe.com/thread-217-1-1.html #include <stdlib.h>#include <string.h>#include <app_mem.h>#include <imath.h>struct……继续阅读 » 水墨上仙 6年前 (2021-03-22) 1666浏览 2388个赞
C语言实现的万年历#include<stdio.h>#include<conio.h>static char *months[]={"January", "February", "March", "April", ……继续阅读 » 水墨上仙 6年前 (2021-03-22) 2308浏览 478个赞