
C语言程序设计
榴莲尖尖
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
约瑟夫生死游戏
C语言约瑟夫生死游戏原创 2022-06-15 14:45:51 · 339 阅读 · 2 评论 -
顺序栈的基本操作
#include <stdio.h> #include <stdlib.h> #include <string.h> #define maxsize 1024 typedef int ElemType; typedef struct { ElemType stack[maxsize]; //数组 int top; //当前元素位序 } seqstack; //初始化栈 seqstack *InitStack(){ seqstack.原创 2021-10-13 16:51:12 · 218 阅读 · 0 评论 -
C语言单链表定义及各类操作
#include <stdio.h> #include <string.h> #include <stdlib.h> typedef int ElemType; typedef struct LNode{ ElemType data;//数据域 struct LNode *next;//指针域 }LinkList; //初始化单链表 int InitList(LinkList *L){ // L=(LinkList *)malloc(sizeof(LinkL.原创 2021-09-29 16:37:52 · 1602 阅读 · 0 评论 -
链表插入操作
#include <stdio.h> #include <string.h> #include <stdlib.h> typedef int ElemType; typedef struct LNode{ ElemType data;//数据域 struct LNode *next;//指针域 }LinkList; int ListInsert(LinkList *L,int i,ElemType Elem){ if (i<1) { return .原创 2021-09-22 19:26:26 · 426 阅读 · 0 评论 -
C语言数据类型隐式转换
数据类型等级(字节长度) char/short<int<unsigned<long<double; float<double; 赋值语句导致的类型改变 在赋值语句中,=右边的值或表达式在赋值给左边的变量之前,先对右边的值或表达式进行计算,然后对值的数据类型转化为左边变量的数据类型,左边是什么类型,右边就要转换成什么数据类型,可能会导致其类型升级,也可能会导致降级 C语言的数据类型隐式转换 在以下四种情况会进行隐式转换 1、算术运算式中,低类型能够转为高类型 2、赋值表达式中,右原创 2021-01-13 15:20:35 · 778 阅读 · 0 评论 -
C语言scanf连续输入两个字符
C语言scanf函数连续输入两个字符出现的问题 上代码 //初始代码,输入1,2,a,b,每次输入按了一次回车 int a,b; char c,d; scanf("%d%d",&a&b); scanf("%c%c",%c&d); printf("%d\n%d\n",a,b); printf("%c\n%c",c,d); //预期输出1,2,a,b //结果输出 1 2 a //上一行不是没有,是一个回车字符 根本原因: scanf函数是从标准缓冲区读取字符的,由于每次输入之后都原创 2021-01-26 09:55:32 · 21984 阅读 · 14 评论 -
C语言数组名作为函数参数
数组名作为函数参数传递时,会将数组整个传递给目标函数 int main(){ int import(),returnNum; int num[10]={1,2,3,4,5}; returnNum= import(num); printf("%d\n",returnNum ); return 0; } //函数类型不指定,则默认为int型 int import(int a[10]){ for (int i = 0; i < 10; ++i) { printf("%d\n",a[i]原创 2021-02-10 14:11:25 · 8375 阅读 · 5 评论 -
C语言位运算
正数的原码反码补码都相同 负数的原码与正数原码相同,但最高位为1 负数反码为其原码除最高位外,按位取反,0变1,1变0 负数补码为反码个位加1原创 2021-03-09 16:16:49 · 123 阅读 · 0 评论 -
C语言专升本例题
1.有下列代码,求最终s值 int s=0,k; for(k=7;k>=0;k--){ printf("for循环进入k值为%d\n",k); switch(k){ case 1:printf("k为%d,此时s为%d\n",k ,s); case 4:printf("k为%d,此时s为%d\n",k ,s ); case 7:s++;printf("k为%d,此时s为%d\n",k ,s );break; case 2:printf("k为%d,此时s为%d\n",原创 2021-03-10 16:57:04 · 4462 阅读 · 0 评论 -
C语言常考库函数
数学函数 头文件:#include <math.h> 或:#include “math.h” abs fabs pow sqrt int a=2,b=-3; float x=2,y=3,z=-4; abs,返回参数的绝对值,函数类型为int printf("%d",abs(b));//3 fabs,返回参数的绝对值,函数类型为double printf("%f",fabs(z));//-4 sqrt,返回非负实数的平方根,函数类型为double printf("%f",sqrt(a))原创 2021-05-22 16:04:20 · 233 阅读 · 0 评论