
C
考班格
一只老菜鸟
展开
-
C语言基础:格式输入输出函数
示例代码:#include<stdio.h> //头文件 int max(int x,int y); //声明max函数 main(){ //main函数 int a,b,c; scanf("%d%d",&a,&b); //格式输入scanf(), %d十...原创 2019-02-23 13:49:27 · 996 阅读 · 0 评论 -
C语言基础:文件的操作
示例代码:文件的打开关闭:void main(){ //main()函数 FILE *fp; //定义一个文件指针*fp if((fp=fopen("D:\\yys.txt","rb"))==NULL){ //fopen()打开指定路径的文件 printf("file ...原创 2019-02-24 17:24:53 · 375 阅读 · 0 评论 -
C语言基础:文件包含功能
示例代码:文件circle.c 推荐使用大写#define PI 3.1415926 //定义PI代替3.1415926 #define CIRCLE(r) 2*PI*(r) //定义CIRCLE(r) 代替2*PI(r) #define AREA(r) PI*(r)*(r) #define SURFICE(r) AREA(r)...原创 2019-02-24 16:23:52 · 295 阅读 · 0 评论 -
C语言基础:编译预处理
示例代码: 宏定义:#define 宏明 字符串(或数值) #define M 5 //宏定义 #define P printf main(){ //main()函数 int f[M],max,min; int i; printf("Please enter M number:\n"); ...原创 2019-02-24 16:12:26 · 168 阅读 · 0 评论 -
C语言基础:枚举
示例代码:#include<stdio.h> //头文件 main(){ //main()函数 enum week{ //定义枚举,并初始化 sun, mon, tue, ...原创 2019-02-24 16:02:28 · 151 阅读 · 0 评论 -
C语言基础:共用体
共用体和结构体不同点:1,同一时刻,共用体中只存放一个被选中的成员,结构体的所有成员都存在, 2,对共用体的不同成员赋值,将会对其他成员重写,原来的值就不存在了,结构体不影响共用体数据中所有成员占用相同的内存单元。关键字:union示例代码:union stu{ ...原创 2019-02-23 20:30:57 · 1050 阅读 · 0 评论 -
C语言基础:链表
示例代码:struct node{ //使用递归结构处理链表 int data; struct node *next; }; struct node *creatlist(){ //创建链表的函数*createlist() struct node *h,*p,*q; //h头节点,p...原创 2019-02-23 19:57:15 · 211 阅读 · 0 评论 -
C语言基础:结构体
示例代码:#include<stdio.h> //头文件 //结构体,嵌套结构体 struct student{ //结构体 struct关键字修饰 int number; //学号 char name[20]; ...原创 2019-02-23 18:52:23 · 214 阅读 · 0 评论 -
C语言基础:指针
示例代码:输入一个数,存放到指针p所指定的内存地址中 int a,*p; p=&a; printf("Please enter a number:\n",*p); scanf("%d",p); printf("*p=%d\n",*p);使用指针操作数组 int m[5],i,*pm; pm=m; ...原创 2019-02-23 16:12:29 · 410 阅读 · 0 评论 -
C语言基础:函数
示例代码:main(){ int max(int a,int b,int c); int z,m,n,y,x; printf("Please input four numbers:\n"); scanf("%d %d %d %d",&x,&y,&z,&m); //输入四个数,输出最大值 n=ma...原创 2019-02-23 15:03:53 · 209 阅读 · 0 评论 -
C语言基础:数组以及字符串操作函数
示例代码: int n,i,m,x,min,min_m,a[100]; printf("Please input the value of n:"); scanf("%d",&n); //输入n个数字...原创 2019-02-23 14:51:36 · 545 阅读 · 0 评论 -
C语言基础:循环语句
示例代码:while:语句输出1-->10阶乘,当i>10结束循环long int i=1,mul=1; while(i<=10){ mul=mul*i; i++; } printf("\n%ld\n",mul); do while:语句:循环体至少执行一次,long int i=1,mul=...原创 2019-02-23 14:23:18 · 270 阅读 · 0 评论 -
C语言基础:if语句switch语句
示例代码:if else :语句 char c; scanf("%c",&c); 输入一个char类型字符赋值给c if('0'<=c&&c<='9') printf("c=%c--->%c",c,'A'); //判断是数字输出...原创 2019-02-23 14:11:43 · 1443 阅读 · 0 评论 -
C语言基础:基本数据类型
示例代码:#include<stdio.h> //头文件 main(){ //main()函数 int n; //int 类型 short s; //short 类型 un...原创 2019-02-23 13:58:24 · 230 阅读 · 0 评论 -
C语言基础:常见算法
#include<stdio.h> int prime(int m); int isPerfect(int n,int a[]); void selectSort(int a[],int n); void bubbleSort(int a[],int n); int search(int a[],int n,int x); void converse(int n,i...原创 2019-02-24 21:30:54 · 859 阅读 · 0 评论