摘要:
C# 使用辗转相除法计算两数的最大公因数及最小公倍数 using System; namespace Program { static class Program { static int Main(string[] args) { int x = 42, y = 12; while (x!=y) 阅读全文
2022年3月21日 #
摘要:
C语言循环求阶乘 #include<iostream> long factorial(int n); int main(int cmd_length, char ** cmd_args) { printf("%d\n",factorial(9)); return(0); } long factori 阅读全文
摘要:
C语言 分别用链表、数组两种方式实现队列存储结构 用链表实现队列 // 队列是先进先出的一种数据存储结构,本例中实现了入队出队便利及清空。 #include <stdio.h> #include <malloc.h> #define NULL 0 typedef struct node { int 阅读全文
摘要:
C语言 实现链表 链表概念 链表是一种物理存储单元上非连续、非顺序的存储结构,数据元素的逻辑顺序是通过链表中的指针链接次序实现的。 链表由一系列结点(链表中每一个元素称为结点)组成,结点可以在运行时动态生成。 每个结点包括两个部分:一个是存储数据元素的数据域,另一个是存储下一个结点地址的指针域。 相 阅读全文
摘要:
栈 Stack 介绍 栈(stack)又名堆栈,它是一种运算受限的线性表。限定仅在表尾进行插入和删除操作的线性表。这一端被称为栈顶,相对地,把另一端称为栈底。 向一个栈插入新元素又称作进栈、入栈或压栈,它是把新元素放到栈顶元素的上面,使之成为新的栈顶元素; 从一个栈删除元素又称作出栈或退栈,它是把栈 阅读全文
摘要:
用C语言实现从1+2+3+n+100 #include <stdio.h> int plus(int); int main(void) { int n = 0; n = plus(n); printf("%d\n",n); return 0; } int plus(int n) { return n 阅读全文
摘要:
test1.c //error #include <stdio.h> int main(void) { int i = 5; const int *p = &i; printf("%d\n",*p); *p = 10; printf("%d\n",*p); return 0; } test2.c / 阅读全文
摘要:
定义基本类型的别名 #include <stdio.h> typedef int Integer; int main(void) { Integer a = 5,b = 10; printf("%d\n",a+b); return 0; } /* typedef不是必须声明在函数外,也可以声明在一个 阅读全文
摘要:
#include <stdio.h> #include <malloc.h> int *LoadInt(int); int main(void) { int x = 0; int *p; p = LoadInt(20); while(x < 20) { printf("%d\n",p[x]); x+ 阅读全文
摘要:
指向无参函数的指针 #include <stdio.h> int Integer(void); char Char(void); int main(void) { int (*a)() = Integer; char (*b)() = Char;; printf("%d\n%c\n",a(),b() 阅读全文
摘要:
用指针作形参,实现输出参数,交换两变量的值。 #include <stdio.h> void jiaohuan(int *,int *); int main(void) { int a=100,b=200; jiaohuan(&a,&b); printf("%d\n%d\n",a,b); retur 阅读全文
摘要:
C语言多级指针 (指向指针的指针) #include <stdio.h> int main(void) { int i = 100,j = 200; int *p; int **q; int ***l; p = &i; q = &p; l = &q; printf("%d\n%d\n%d\n%d\n 阅读全文
摘要:
C语言 enum 枚举常量 #include <stdio.h> enum WeekDay { MonDay,TuesDay,WednesDay = 5,ThursDay,FriDay,SaturDay,SunDay }; int main(void) { enum WeekDay Day = Fr 阅读全文
摘要:
C语言共用体 union #include <stdio.h> union U1 { unsigned char c [3];unsigned int i; }; union U2 { char c[15]; int i; }; int main(void) { union U1 u1; union 阅读全文
摘要:
C语言使用指针指向结构体 #include <stdio.h> struct Student { char name; int age; }; int main(void) { struct Student a,*p; p = &a; p->name = 'a'; p->age = 12; prin 阅读全文
摘要:
C语言结构体类型 #include <stdio.h> struct Student { char name; int age; }; int main(void) { struct Student a = {'a',12};; printf("name:%c\nage:%d\n",a.name,a 阅读全文
摘要:
C语言前自增自减(c、--c)和后自增自减(c、c--)的区别? #include <stdio.h> int main(void) { int i = 5; i++; printf("%d\n",i); printf("%d\n",i++); printf("%d\n",i); printf("% 阅读全文
摘要:
C语言基本数据类型的意义,如何灵活运用? #include <stdio.h> int main(void) { int i = 1094795585; //该值占四个字节,每个字节都是十进制的六十五 char *p = (char *)&i; printf("%d\n%d\n%d\n%d\n",p 阅读全文
摘要:
键盘 键盘是计算机的主要输入设备之一,中文汉字、英文字母、数字以及标点符号就是通过键盘输入计算机的。不同的击键和击键序列代表了您将要计算机准备执行的不同命令,我们只要通过敲击键盘上面的不同键位,输入不同的指令,计算机就会根据你的指令去完成各项工作。键盘的款式有很多种,我们通常使用的有101键、104 阅读全文
摘要:
变量说明符 C 语言允许声明变量的时候,加上一些特定的说明符(specifier),为编译器提供变量行为的额外信息。它的主要作用是帮助编译器优化代码,有时会对程序行为产生影响。 const const说明符表示变量是只读的,不得被修改。 const double PI = 3.14159; PI = 阅读全文