C语言学习
酱油码
这个作者很懒,什么都没留下…
展开
-
简章链表实现
list.h#include <stdio.h>#include<stdlib.h>typedef struct student { int num; float score; struct student *pNextStu;}student_t,*pStudent_t;//链表头插法方法的声明void ListHeadInsert(pStudent_t* pphead, pStudent_t * pptail, int val);//链表尾插法方法的声明v原创 2021-03-17 15:06:09 · 101 阅读 · 0 评论 -
共用体与枚举
共用体使几个不同的变量共占一段内存的结构称为“共用体”类型的结构。共用体变量所占的内存长度等于最长的成员的长度union 共用体名{成员列表}变量列表;#include <stdio.h>#include <stdlib.h>union data { int i; char c; float f;};typedef struct Student { int num; float score;}student_t;int main() { uni原创 2021-03-15 08:31:12 · 116 阅读 · 0 评论 -
C语言-结构体与结构指针
结构体的定义-引用-初始化声明一个结构体类型的一般形式为struct 结构体名{成员列表};如: struct student { int num; char name[20]; char sex; int age; float score; char addr[30]; }; struct student student1, student2;先声明结构体类型再定义变量名,例如:struct student student1, student2;...原创 2021-03-12 09:49:44 · 225 阅读 · 0 评论 -
C语言之字符串翻转
# include<stdio.h># include<stdlib.h># include<string.h>void wordReverse(char *start,char * end) { char tmp; while (start<end) { tmp = *start; *start = *end; *end = tmp; start++; end--; }}int main() { char str[1000].原创 2021-03-11 21:46:49 · 276 阅读 · 0 评论 -
C语言之指针
指针与自增、自减运算符# include<stdio.h># include<stdlib.h># include<string.h>//只有比后增优先级高的操作符,才会作为一个整体,如()、[]int main() { int a[3] = { 2,7,8 }; int *p; int j; p = a; j = *p++;//先把*p的值赋给j,然后对p加1,p为指针变量 printf("a[0]=%d,j=%d,*p=%d\n",a[0],j原创 2021-03-10 16:43:19 · 1147 阅读 · 0 评论 -
C语言之循环打印的相关题目
打印下面图形# include<stdio.h># include<stdlib.h># include<string.h>//打印下列图形// *// * *// * * *// * * * *// * * * * *// * * * *// * * *// * *// *int main() { int i; for (i = 0; i < 9;++i) { int .原创 2021-03-10 14:41:10 · 223 阅读 · 0 评论 -
C语言之数组
一维数组声明数组时要遵循以下规则1.数组名的命令规则和变量名的相同,即遵循标识符命名规则。2.在定义数组时,需要指定数组中元素的个数,方括号中的常量表达式用来表示元素的个数,即数组长度。3.常量表达中可以包含常量和符号常量,但不能包含变量。也就是说,C语言不允许对数组的大小做动态定义,即数组的大小依赖于程序运行过程中变量的值。一维数组的存储及函数传递# include<stdlib.h># include<stdio.h>//一维数组的传递,数组长度无法传递给子函数原创 2021-03-09 19:34:39 · 4013 阅读 · 0 评论 -
有关异或的题目
有关异或的题目1.有101个整数,其中有50个数出现了两次,1个数出现了1次,找出出现了一次的那个数。异或:相同数字得到0,任何数与零异或,最终得到自身,同时异或满足交换律。# include<stdlib.h># include<stdio.h>int main() { int a[13] = { 1,2,3,4,5,6,17,1,2,3,4,5,6 }; int result = 0; for (int j = 0; j <= sizeof(a)/4原创 2021-03-08 20:29:04 · 518 阅读 · 0 评论 -
C语言学习
跟龙哥学C语言进制转换将十进制转换成二进制。输入十进制数,输出对应的二进制数,按组合键Ctrl+Z结束# include<stdlib.h># include<stdio.h>#define N 2int main() { int m, r; int binary[50]; int decimal; while (scanf("%d", &decimal) != EOF) { int i = 0; m = decimal; while (m/N!=原创 2021-03-08 17:33:51 · 142 阅读 · 0 评论