C语言求0—7所能组成的奇数个数main(){long sum=4,s=4;int j;for(j=2;j<=8;j++)/*j is place of number*/{ printf("\n%ld",sum);if(j<=2)s*=7;elses*=8;sum+=s;}printf("……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2592浏览 643个赞
C语言验证一个偶数总能表示为两个素数之和#include "stdio.h"#include "math.h"main(){ int a,b,c,d;scanf("%d",&a);for(b=3;b<=a/2;b+=2){ for(c=2;c<=sqrt(b);……继续阅读 » 水墨上仙 4年前 (2021-03-22) 3101浏览 439个赞
C语言判断一个素数能被几个9整除 main(){ long int m9=9,sum=9;int zi,n1=1,c9=1;scanf("%d",&zi);while(n1!=0){ if(!(sum%zi))n1=0;else{m9=m9*10;sum=sum+m9;c9++;}}printf(&……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2088浏览 1582个赞
C语言两个字符串连接程序#include "stdio.h"main(){char a[]="acegikm";char b[]="bdfhjlnpq";char c[80],*p;int i=0,j=0,k=0;while(a[i]!='\0'&&am……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1261浏览 897个赞
某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换。main(){int a,i,aa[4],t;scanf("%d",&a);aa[0]=a%10;aa[1]=a%100/10;aa[2……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2653浏览 1928个赞
C语言归并排序算法演示代码#include <iostream> using namespace std; void merge(int*,int,int,int); void mergesort(int *a, int low,int high){ int pivot; if(low<……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2473浏览 325个赞
解释如下:双斜杠之后是注释掉的.前面http:相当于一个goto的标签#include <stdio.h>int main(){ http://www.shello.name/ printf("haha!!\n"); return 0;}……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1389浏览 2845个赞
C语言中function(void)与function()的区别 看下面代码的编译结果void foo1(){}void foo2(void){}main(){ foo1(1); foo2(1); }编译:1.c: In&……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2939浏览 1964个赞
C语言找出大于一个数的最小回文数#include <stdio.h>#include <stdlib.h>#include <string.h>/***********************************************************************************……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2929浏览 2087个赞
C语言按层次遍历二叉树算法#define MaxSize 1000typedef char ElemType; typedef struct node { ElemType data; struct node *lchild; struct node *rchild;} BTNode;//创建二叉树void CreateBTNode(……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2224浏览 139个赞
汉诺塔:汉诺塔(又称河内塔)问题是源于印度一个古老传说的益智玩具。大梵天创造世界的时候做了三根金刚石柱子,在一根柱子上从下往上按照大小顺序摞着64片黄金圆盘。大梵天命令婆罗门把圆盘从下面开始按大小顺序重新摆放在另一根柱子上。并且规定,在小圆盘上不能放大圆盘,在三根柱子之间一次只能移动一个圆盘。#include<stdio.h>#in……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2716浏览 2890个赞
Linux环境下C语言实现贪吃蛇游戏[liul@test snake]$ more snake.c #include <stdio.h>#include <stdlib.h>#include <curses.h>#include <signal.h>#include <sys/time.h……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1949浏览 2833个赞
java二叉树查找、遍历、添加与删除package com.structures.tree;import java.util.ArrayList;import java.util.NoSuchElementException;import java.util.Stack;/* * Binary Search Tree */public ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2156浏览 1849个赞
C语言分割字符串strtok函数int argc = 0; char** argv = (char **) malloc(30 * sizeof(char *)); char *token = NULL; const char* delim = ","; const char* str = "My……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1941浏览 2153个赞
C语言基础:格式化浮点数输出#include <stdio.h>int main () { float value = 1.23456; printf ("%8.1f\n", value); printf ("%8.3f\n", value); printf ("……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2665浏览 1271个赞
C语言基础:for循环里矢量2个循环因子变量#include <stdio.h>int main() { int i, j; for (i = 0, j = 100; i <= 100; i++, j++) printf("i = %d j = %d\n", i, j);return 1……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2729浏览 2797个赞
C语言二叉树遍历代码来自于郝斌老师的数据结构#include<stdio.h>#include<malloc.h>struct BTNode{char data;struct BTNode * pLchild;struct BTNode * pRchild;};void PreTraverseBTree(stru……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2649浏览 2941个赞
C语言基础:for循环语句使用范例演示#include <stdio.h>int main () { int counter; for (counter = -100; counter <= 100; counter += 5) printf("%d ", counter); prin……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2207浏览 891个赞
C语言基础:for从大到小循环语句范例#include <stdio.h>int main () { int counter; for (counter = 5; counter >= 1; counter--) printf("%d ", counter); printf("……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1800浏览 2252个赞
C语言基础:for循环演示代码,字符循环和浮点数循环#include <stdio.h>int main () { char letter; float percent; for (letter = 'A'; letter <= 'Z'; letter++) pu……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2209浏览 760个赞
C语言基础:格式化输出带符号的数字#include <stdio.h>int main () { int int_value = 5; printf("Left justifed with sign %-+3d\n", int_value);return 1; } ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2176浏览 2921个赞
C语言基础:goto语句用法演示#include <stdio.h>int main() { int count = 1; label: printf("%d ", count++); if (count <= 100) goto label;retu……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1939浏览 2623个赞
C语言基础:一个无限循环程序(死循环,不要运行)#include <stdio.h>int main () { int i; int result = 0; int value = 1; for (i = 0; i < 100; i++) { printf("%d "……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1372浏览 1714个赞
C语言基础:格式化整数输出#include <stdio.h>int main () { int value = 5; printf ("%1d\n", value); printf ("%2d\n", value); printf ("%3d\n", ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1486浏览 2925个赞
C语言基础:while语句使用范例#include <stdio.h>int main() { int counter = 1; // Initialize the control variable while (counter <= 100) // Test the control variable ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 3041浏览 408个赞
C语言基础:向左向右对其输出数字#include <stdio.h>int main () { int int_value = 5; float flt_value = 3.33; printf("Right justified %5d value\n", int_value); printf……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2657浏览 2716个赞
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……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1977浏览 2607个赞
C语言基础:求模和取余演示#include <stdio.h>int main () { int remainder; int result; result = 10 / 3; remainder = 10 % 3; printf("10 Divided by 3 is %d Remainder ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1423浏览 197个赞
C语言基础:输出100以内的奇数和偶数#include <stdio.h>int main() { int counter; printf("\nEven values\n"); for (counter = 1; counter <= 100; counter++) { ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2050浏览 2233个赞
1. RSA说明RSA公钥加密算法是1977年由Ron Rivest、Adi Shamirh和LenAdleman在(美国麻省理工学院)开发的。RSA取名来自开发他们三者的名字。RSA算法基于一个十分简单的数论事实:将两个大素数相乘十分容易,但那时想要对其乘积进行因式分解却极其困难,因此可以将乘积公开作为加密密钥。2. RSA算法实现RSA算法是一种非对称密……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1748浏览 2735个赞
C语言基础:将整数格式化成其它进制输出,如8进制,16进制#include <stdio.h>int main () { int value = 255; printf("The decimal value %d in octal is %o\n", value, value); p……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1383浏览 1884个赞
C语言基础:自增自减符号位置的区别,– a和a–的区别演示#include <stdio.h>int main () { int value = 1; printf("Using postfix %d\n", value--); printf("Valu……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1846浏览 2416个赞
C语言基础:break语句使用范例代码#include <stdio.h>int main() { int counter; for (counter = 1; counter <= 100; counter++) { if (counter == 50) break; ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1474浏览 1391个赞
C语言基础:结构体及指针使用范例#include <stdio.h>#include <alloc.h>int main(void) { int i; struct ListEntry { int number; struct ListEntry *next; } start, *no……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2975浏览 1750个赞
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++) ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2035浏览 145个赞
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"……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2100浏览 452个赞
《C++ Primer》中说:在C++中没有多维数组,只有元素师数组的数组。如:要想创建一个二维整数数组,首先要创建一个一维动态数组,它由int *类型的指针构成。int*就是这个一维int指针数组的类型。// String.cpp : Defines the entry point for the console application.//#……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2457浏览 1493个赞
C语言基础:输出变量的内存地址#include <stdio.h>int main(void) { int count = 1; float salary = 40000.0; long distance = 1234567L; printf("Address of count is %x\n"……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1443浏览 977个赞
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"……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2085浏览 364个赞
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……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1269浏览 1094个赞
C语言基础:两个获取数组地址的方法#include <stdio.h>int main(void) { int count[10]; float salaries[5]; long distances[10]; printf("Address of the array count is %x &……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2444浏览 1422个赞
C语言基础:数组作为函数参数调用代码演示#include <stdio.h>void show_array(int values[], int number_of_elements) { int i; for (i = 0; i < number_of_elements; i++) printf("%……继续阅读 » 水墨上仙 4年前 (2021-03-22) 2260浏览 1378个赞
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……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1470浏览 1625个赞
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; ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1683浏览 1001个赞
C语言基础:修改结构体数据#include <stdio.h>struct Shape { int type; int color; float radius; float area; float perimeter;};void change_structure(struct Shape *shape) { ……继续阅读 » 水墨上仙 4年前 (2021-03-22) 1292浏览 2584个赞