C 购买商品的游戏
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 /* 5 *模拟实现道具店购物功能(商店暂时只支持一种类型的商品) 6 *商品具备名称,价格,库存等属性 7 *模拟玩家购买游戏道具 8 *1.玩家选择要购买的道具
阅读全文
posted @
2021-07-30 12:45
Bytezero!
阅读(146)
推荐(0) 编辑
C语言基础知识
摘要:C语言: C 语言是一种通用的高级语言,最初是由丹尼斯·里奇在贝尔实验室为开发 UNIX 操作系统而设计的。C 语言最开始是于 1972 年在 DEC PDP-11 计算机上被首次实现。 在 1978 年,布莱恩·柯林汉(Brian Kernighan)和丹尼斯·里奇(Dennis Ritchie)
阅读全文
posted @
2021-07-28 12:35
Bytezero!
阅读(144)
推荐(0) 编辑
运行第一个程序!hello world!
摘要:第一个程序:1 //打印 hello world 2 3 #include <stdio.h> 4 int main() 5 { 6 printf("hello world!\n"); 7 return 0; 8 } 打印结果:
阅读全文
posted @
2021-07-28 12:34
Bytezero!
阅读(78)
推荐(0) 编辑
输出两个字符
摘要:1 //输出两个字符 #include <stdio.h> 2 int main () 3 { 4 5 int NB = 789; 6 int CB = 333; 7 printf("NB的数字为:%d\n%d:是CB的数字\n",NB,CB); 8 }
阅读全文
posted @
2021-07-28 12:33
Bytezero!
阅读(147)
推荐(0) 编辑
输出长方形的 长 宽 高 和 面积
摘要:1 //输出长方形的 长 宽 高 和 面积 2 3 #include <stdio.h> 4 int main () 5 { 6 float high = 1.23f; 7 float width = 4.23f; 8 float lengh = 5.56f; 9 10 float ice = hi
阅读全文
posted @
2021-07-28 12:32
Bytezero!
阅读(235)
推荐(0) 编辑
大写字母与小写字母 相差 一个 空格 A = 65 a = 97 空格 = 32
摘要:1 //大写字母与小写字母 相差 一个 空格 A = 65 a = 97 空格 = 32 2 3 #include <stdio.h> 4 int main() 5 { 6 7 char ch = 'a'; 8 char ch2 = 'A'; 9 char ch1 = ' '; 10 printf(
阅读全文
posted @
2021-07-28 12:31
Bytezero!
阅读(474)
推荐(0) 编辑
C数据类型
摘要:在 C 语言中,数据类型指的是用于声明不同类型的变量或函数的一个广泛的系统。变量的类型决定了变量存储占用的空间,以及如何解释存储的位模式。 C 中的类型可分为以下几种:
阅读全文
posted @
2021-07-28 12:31
Bytezero!
阅读(204)
推荐(0) 编辑
接收用户输入的小写字母,转换为大写字母并展示
摘要:1 //接收用户输入的小写字母,转换为大写字母并展示 2 3 4 #include <stdio.h> 5 int main() 6 { 7 char num; 8 printf("请输入一个小写字母:"); //a 9 scanf("%c",&num); 10 printf("转换大写字母为:%c
阅读全文
posted @
2021-07-28 12:30
Bytezero!
阅读(332)
推荐(0) 编辑
C运算符(算数运算符)
摘要:运算符是一种告诉编译器执行特定的数学或逻辑操作的符号。C 语言内置了丰富的运算符,并提供了以下类型的运算符: 算术运算符 关系运算符 逻辑运算符 位运算符 赋值运算符 杂项运算符 1 //实列 2 3 #include <stdio.h> 4 5 int main() 6 { 7 int a = 2
阅读全文
posted @
2021-07-28 12:29
Bytezero!
阅读(264)
推荐(0) 编辑
C语言运算符(位运算符)+(赋值运算符)
摘要:实列 1 #include <stdio.h> 2 3 int main() 4 { 5 6 unsigned int a = 60; /* 60 = 0011 1100 */ 7 unsigned int b = 13; /* 13 = 0000 1101 */ 8 int c = 0; 9 10
阅读全文
posted @
2021-07-28 12:28
Bytezero!
阅读(204)
推荐(0) 编辑
C语言运算符(关系运算符)+(逻辑运算符)
摘要:下表显示了 C 语言支持的所有关系运算符。假设变量 A 的值为 10,变量 B 的值为 20,则: 实列: 1 #include <stdio.h> 2 3 int main() 4 { 5 int a = 21; 6 int b = 10; 7 int c ; 8 9 if( a == b ) 1
阅读全文
posted @
2021-07-28 12:28
Bytezero!
阅读(243)
推荐(0) 编辑
C语言运算符(杂项运算符 ↦ sizeof & 三元)
摘要:实列 1 #include <stdio.h> 2 3 int main() 4 { 5 int a = 4; 6 short b; 7 double c; 8 int* ptr; 9 10 /* sizeof 运算符实例 */ 11 printf("Line 1 - 变量 a 的大小 = %lu\
阅读全文
posted @
2021-07-28 12:28
Bytezero!
阅读(140)
推荐(0) 编辑
C 中的运算符优先级
摘要:运算符的优先级确定表达式中项的组合。这会影响到一个表达式如何计算。某些运算符比其他运算符有更高的优先级,例如,乘除运算符具有比加减运算符更高的优先级。 例如 x = 7 + 3 * 2,在这里,x 被赋值为 13,而不是 20,因为运算符 * 具有比 + 更高的优先级,所以首先计算乘法 3*2,然后
阅读全文
posted @
2021-07-28 12:27
Bytezero!
阅读(218)
推荐(0) 编辑
除法 取模 后置 前置
摘要:1 //除法 取模 后置 前置 2 3 4 #include <stdio.h> 5 int main() 6 { 7 //float num1 = 5.0; 8 //float num2 = 2.0; 9 int num1 = 5,num2 = 2; //整形输出整形 float行输出小数点 10
阅读全文
posted @
2021-07-28 12:26
Bytezero!
阅读(51)
推荐(0) 编辑
用 getchar putchar 来输入和接收 但是要清空缓冲区
摘要:1 //用 getchar putchar 来输入和接收 但是要清空缓冲区 2 3 #include <stdio.h> 4 int main() 5 { 6 char ch1,ch2; 7 printf("请输入一个字符"); //a 8 ch1 = getchar(); //接收字符 9 ffl
阅读全文
posted @
2021-07-28 12:23
Bytezero!
阅读(90)
推荐(0) 编辑
数字交换
摘要:1 //数字交换 2 #include<stdio.h> 3 int main() 4 { 5 int first ; 6 int second; 7 int third; 8 //交换前的数字 9 printf("\n请输入第一个数字:"); 10 scanf("%d",&first); 11 1
阅读全文
posted @
2021-07-28 12:20
Bytezero!
阅读(178)
推荐(0) 编辑
测试 前置 ++ 后置--
摘要:注意:前置 ++ 要先算 后置++ 最后程序运行完 然后再++1 #include <stdio.h> 2 int main() 3 { 4 int num = 10; 5 int result = --num < 20 && num++ >=9; 6 printf("result = %d\tnu
阅读全文
posted @
2021-07-28 12:18
Bytezero!
阅读(61)
推荐(0) 编辑
(1)用 if语句 区间判断
摘要:/*此例子只做比喻演示*/ 1 #include <stdio.h> 2 int main() 3 { 4 5 int p; 6 scanf("%d",&p); 7 if(p > 9999) 8 { 9 printf("走吧去结婚"); 10 } 11 else if (p>1000 && p<=9
阅读全文
posted @
2021-07-28 12:16
Bytezero!
阅读(334)
推荐(0) 编辑
(2)用 if语句 区间判断
摘要:1 /*此例子只作为演示*/ 2 3 #include <stdio.h> 4 int main() 5 { 6 printf("请问贵公司给出的薪资是:\n"); 7 8 double c ; 9 10 //printf("我们给出的是:"); 11 scanf("%lf",&c); 12 13
阅读全文
posted @
2021-07-28 12:14
Bytezero!
阅读(333)
推荐(0) 编辑
100的累加和 while 循环
摘要://100的累加和 while 循环 #include <stdio.h> int main() { int sum = 0; //5050 int i = 0; while(i < 101) { sum = sum +i; i++; } printf("%d\n",sum); }
阅读全文
posted @
2021-07-28 12:12
Bytezero!
阅读(168)
推荐(0) 编辑
密码三次就会锁掉 while 循环
摘要:while 只要给定的条件为真,C 语言中的 while 循环语句会重复执行一个目标语句 一般定义 //return_type function_name( parameter list ) //{ // body of the function //} 在 C 语言中,函数由一个函数头和一个函数主
阅读全文
posted @
2021-07-28 12:12
Bytezero!
阅读(316)
推荐(0) 编辑
100的累加和 for循环
摘要:1 int main() 2 { 3 int sum ; 4 int i; 5 for(i = 0; i<101; i++) 6 { 7 sum += i; 8 } 9 printf("100的累加和为:%d",sum); //5050 10 }
阅读全文
posted @
2021-07-28 12:10
Bytezero!
阅读(293)
推荐(0) 编辑
取个位数
摘要:1 #include <stdio.h> 2 int main() 3 { 4 5 int num = 123456; 6 while(num>0) 7 { 8 9 10 printf("%d\n",num % 10); 11 num=num/10; //去掉取掉的最后一位 12 }
阅读全文
posted @
2021-07-28 12:09
Bytezero!
阅读(101)
推荐(0) 编辑
求6个月的平均工资
摘要:1 #include <stdio.h> 2 int main () 3 { 4 double salary ; //工资 5 double total_salary = 0; 6 double adv_salary; 7 int i ; 8 for(i = 0;i < 6;i++) 9 { 10
阅读全文
posted @
2021-07-28 12:07
Bytezero!
阅读(110)
推荐(0) 编辑
输入一个数字,找出整数相加都等于输入的数字
摘要:1 //输入一个数字,找出整数相加都等于输入的数字 2 3 4 #include <stdio.h> 5 int main() 6 { 7 int num ; 8 int i ; 9 printf("请输入一个数字: "); //6 10 scanf("%d",&num); 11 12 for( i
阅读全文
posted @
2021-07-28 12:04
Bytezero!
阅读(83)
推荐(0) 编辑
用 区间判断(if)来猜价格的高低
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() 4 { 5 int price = 150; 6 int guess ; 7 int i = 0; 8 9 10 for(;i<5 ;i++) 11 { 12 13 printf("请输入
阅读全文
posted @
2021-07-28 12:02
Bytezero!
阅读(192)
推荐(0) 编辑
1-100之间的偶数和
摘要:#include<stdio.h> int main() { int i =1; int sum = 0; for(i = 0; i <101; i++) { if( i % 2 == 0) { sum += i; } } printf("%d\n",sum); }
阅读全文
posted @
2021-07-28 12:00
Bytezero!
阅读(509)
推荐(0) 编辑
C语言数组
摘要:C 语言支持数组数据结构,它可以存储一个固定大小的相同类型元素的顺序集合。数组是用来存储一系列数据,但它往往被认为是一系列相同类型的变量。 数组的声明并不是声明一个个单独的变量,比如 runoob0、runoob1、...、runoob99,而是声明一个数组变量,比如 runoob,然后使用 run
阅读全文
posted @
2021-07-28 11:57
Bytezero!
阅读(108)
推荐(0) 编辑
数组 累加 查找
摘要:1 #include <stdio.h> 2 int main() 3 { 4 int nums[] = {8,4,2,1,23,344,12}; 5 int i; 6 int sum = 0; 7 double avg; 8 9 int searchNum; 10 11 //打印 数组里的元素 1
阅读全文
posted @
2021-07-28 11:55
Bytezero!
阅读(68)
推荐(0) 编辑
数组 动态录入
摘要:1 //动态录入 2 3 #include <stdio.h> 4 # define N 5 5 int main() 6 { 7 8 double score[5]; //数组5 个元素 9 int i; // 循环变量 10 for(i = 0; i < N; i++) 11 { 12 prin
阅读全文
posted @
2021-07-28 11:54
Bytezero!
阅读(78)
推荐(0) 编辑
数组中的元素降序排列
摘要:1 #include <stdio.h> 2 #define N 7 3 4 int main() 5 { 6 7 int nums [N] = {10,85,96,5,9,6,200}; //定义了一个数组,里面有 7 个元素 8 int i ,j; 9 int temp; 10 11 //外层循
阅读全文
posted @
2021-07-28 11:50
Bytezero!
阅读(513)
推荐(0) 编辑
数组 查询 增加 删除 排序
摘要:1 //数组 查询 增加 删除 排序 2 3 #include <stdio.h> 4 int main() 5 { 6 7 double power[] = {100,855,600,8960,20}; //定义一个战斗力的数组 8 int count = 5; //元素个数为5 9 10 dou
阅读全文
posted @
2021-07-28 11:49
Bytezero!
阅读(49)
推荐(0) 编辑
二维数组
摘要:1 #include<stdio.h> 2 int main() 3 { 4 //使用二维数组 进行的打印 5 double scores[4][3] = {{87,56,89},{98,55,46},{98,65,56},{98,65,23}}; 6 int i,j; 7 for(i = 0; i
阅读全文
posted @
2021-07-28 11:45
Bytezero!
阅读(32)
推荐(0) 编辑
C 皇帝选妃游戏 结合所学
摘要:1 //皇帝游戏 2 3 //EmperroGame 4 #include <stdio.h> 5 #include <windows.h> 6 #include <mmsystem.h> 7 #include <stdlib.h> 8 #include <string.h> 9 #include
阅读全文
posted @
2021-07-28 11:40
Bytezero!
阅读(185)
推荐(0) 编辑
C指针
摘要:学习 C 语言的指针既简单又有趣。通过指针,可以简化一些 C 编程任务的执行,还有一些任务,如动态内存分配,没有指针是无法执行的。所以,想要成为一名优秀的 C 程序员,学习指针是很有必要的。 正如您所知道的,每一个变量都有一个内存位置,每一个内存位置都定义了可使用 & 运算符访问的地址,它表示了在内
阅读全文
posted @
2021-07-28 11:38
Bytezero!
阅读(47)
推荐(0) 编辑
指针 打印
摘要:1 //指针 2 3 4 5 #include <stdio.h> 6 int main() 7 { 8 int num = 9; 9 int *ptr_num1 = # 10 11 //int *ptr_num2 = &ptr_num; //指针的地址 12 int **ptr_num2
阅读全文
posted @
2021-07-28 11:30
Bytezero!
阅读(156)
推荐(0) 编辑
指针的操作
摘要:1 #include <stdio.h> 2 int main() 3 { 4 int num1 = 1024; 5 int num2 = 2048; 6 int *ptr1; 7 int *ptr2; 8 9 ptr1 = &num1; 10 ptr2 = &num2; 11 printf("nu
阅读全文
posted @
2021-07-28 11:25
Bytezero!
阅读(61)
推荐(0) 编辑
打印数组的元素
摘要:1 //打印数组的元素 2 3 4 #include <stdio.h> 5 int main() 6 { 7 8 //数组名就是数组的首地址 9 // double score[] = {69,43,56,48,52}; 10 // printf("数组的首地址:%p\t数组的首元素地址:%p\t
阅读全文
posted @
2021-07-28 11:20
Bytezero!
阅读(494)
推荐(0) 编辑
指针的 --
摘要:1 指针的 -- 2 3 #include <stdio.h> 4 int main() 5 { 6 int i; 7 double score[5] = {10,20,32,40,50}; 8 double *ptr_score; 9 ptr_score = &score[1]; // 20 10
阅读全文
posted @
2021-07-28 11:15
Bytezero!
阅读(35)
推荐(0) 编辑
指针的打印方式
摘要:1 #include <stdio.h> 2 void main() 3 { 4 int array[]={20,30,40,50,60}; 5 //int *ptr_array; 6 int *ptr_array = array; 7 int i; 8 for(i = 0; i <5;i++) 9
阅读全文
posted @
2021-07-28 11:10
Bytezero!
阅读(625)
推荐(0) 编辑
数组逆序
摘要:1 //数组逆序 2 3 #include <stdio.h> 4 #define N 5 5 int main() 6 { 7 int array[N] = {21,69,85,55,89}; 8 int i; 9 int temp; 10 11 12 //for(i = 0; i< N /2;
阅读全文
posted @
2021-07-28 11:09
Bytezero!
阅读(175)
推荐(0) 编辑
二维数组指针打印
摘要:1 #include <stdio.h> 2 int main() 3 { 4 5 int nums[5][3] = {{10,20,30},{40,50,60},{70,80,90},{100,110,120},{130,140,150}}; 6 int i,j; 7 8 9 // int (*p
阅读全文
posted @
2021-07-28 11:05
Bytezero!
阅读(109)
推荐(0) 编辑
数字转换大写的中文
摘要:1 #include <stdio.h> 2 int main() 3 { 4 5 int moneys[6]; 6 char unit[10][4] ={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"}; 7 int i =0; 8 int money,count
阅读全文
posted @
2021-07-28 11:00
Bytezero!
阅读(53)
推荐(0) 编辑
C中的内置函数
摘要:1 //#include <stdio.h> 2 //#include <ctype.h> 3 //#include <math.h> 4 //#include <stdlib.h> 5 //#include <time.h> 6 7 //int main() 8 //{ 9 10 /* 11 //
阅读全文
posted @
2021-07-28 10:55
Bytezero!
阅读(156)
推荐(0) 编辑
函数调用
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <math.h> 4 //圆的面积 5 void calcCircle(); 6 //矩形的面积 7 void calcRectangle(); 8 //求1-100之间的偶数和 9 int
阅读全文
posted @
2021-07-28 10:50
Bytezero!
阅读(47)
推荐(0) 编辑
函数查找
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 5 6 int search(); 7 8 9 int main() 10 { 11 12 13 int index = search(); 14 printf("找到的元素的下标是:%d\n",index
阅读全文
posted @
2021-07-28 10:45
Bytezero!
阅读(37)
推荐(0) 编辑
实现 pow 函数
摘要:1 ////实现pow函数 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 double power(double,int) ; //函数原型 6 int main() 7 8 { 9 10 printf("%d的%d次幂等于: %.2lf\n",5,2
阅读全文
posted @
2021-07-28 10:35
Bytezero!
阅读(190)
推荐(0) 编辑
C函数调用(2)
摘要:1 //函数调用 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 #include <math.h> 6 //根据传入的半径,返回圆的面积 7 double calcCircle(double); 8 9 //要对用户输入进行非负的判断 10 int v
阅读全文
posted @
2021-07-28 10:35
Bytezero!
阅读(34)
推荐(0) 编辑
C 递归
摘要:递归指的是在函数的定义中使用函数自身的方法。 举个例子:从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?"从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?'从前有座山,山里有座庙,庙里有个老和尚,正在给小和尚讲故事呢!故事是什么呢?……'" 例
阅读全文
posted @
2021-07-28 10:15
Bytezero!
阅读(38)
推荐(0) 编辑
C作用域
摘要:任何一种编程中,作用域是程序中定义的变量所存在的区域,超过该区域变量就不能被访问。C 语言中有三个地方可以声明变量: 在函数或块内部的局部变量 在所有函数外部的全局变量 在形式参数的函数参数定义中 局部变量 在某个函数或块的内部声明的变量称为局部变量。它们只能被该函数或该代码块内部的语句使用。局部变
阅读全文
posted @
2021-07-28 10:05
Bytezero!
阅读(151)
推荐(0) 编辑
查看调用了多少次
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int whileCount = 0; //全局变量,用来记while循环执行的轮数 5 //作用域只在当前的源文件 6 //extern int whileCount; //可以在其他源文件 引用 外部变
阅读全文
posted @
2021-07-28 10:00
Bytezero!
阅读(133)
推荐(0) 编辑
引用传递 传的地址
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 //引用传递 传的地址 5 void change(int *); 6 7 void change(int *num) 8 { 9 *num +=1; 10 } 11 12 int main() 13 {
阅读全文
posted @
2021-07-28 09:55
Bytezero!
阅读(44)
推荐(0) 编辑
书写一个小型的学生成绩管理系统
摘要:1 //书写一个小型的学生成绩管理系统 2 3 #include <stdio.h> 4 #include <stdlib.h> 5 #define N 5 6 //书写一个小型的学生成绩管理系统 7 void input(double []); 8 void sort(double []); 9
阅读全文
posted @
2021-07-28 09:50
Bytezero!
阅读(91)
推荐(0) 编辑
自定义字符串的几种方式
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 //字符串和字符数组的区别:最后一位是否是 \0,空字符 有的为 字符串 没有的 为字数组 6 //所有的字符串都是字符数组 对的 7 //所有的字符数组都是字符串 错的. 8 /
阅读全文
posted @
2021-07-28 09:40
Bytezero!
阅读(393)
推荐(0) 编辑
返回传入字符串的长度
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 //返回传入字符串的长度 6 int GetStrLength(char[]); 7 8 //封装fgets<用来接收字符串的字符数组,接收的字符总数 9 void G
阅读全文
posted @
2021-07-28 09:32
Bytezero!
阅读(137)
推荐(0) 编辑
内置函数 strlen
摘要:1 //内置函数 strlen 2 //计算字符串的实际长度,不含字符串结束标准\0 3 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 8 void main() 9 { 10 11 char words1[] = {
阅读全文
posted @
2021-07-28 09:30
Bytezero!
阅读(57)
推荐(0) 编辑
内置函数 字符串的复制 strcpy
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 6 void main() 7 { 8 9 char str1[50]; 10 char str2[20]; 11 printf("输入目的字符串:"); 12 get
阅读全文
posted @
2021-07-28 09:25
Bytezero!
阅读(49)
推荐(0) 编辑
内置函数 字符串比较 strcmp 登录密码
摘要:1 //内置函数 字符串比较 strcmp 2 // 原理:将两个字符串从首字母开始,按照ASCII码的顺序逐个比较 3 //字符串1 == 字符串2 返回0 4 //字符串1 < 字符串2, 返回正数 5 //字符串1 > 字符串2 ,返回负数 6 7 #include<stdio.h> 8 #i
阅读全文
posted @
2021-07-28 09:20
Bytezero!
阅读(149)
推荐(0) 编辑
字符串连接 strcat
摘要:1 //字符串连接 strcat 2 //将一个字符串连接到另一个字符串的末尾,组合成一个新字符串 3 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 8 void main() 9 { 10 char str1[200
阅读全文
posted @
2021-07-28 09:10
Bytezero!
阅读(127)
推荐(0) 编辑
实现字符串的加密与解密
摘要://实现字符串的加密与解密//加密方式:将字符串中每个字符加上它在字符中的位置和一个偏移量 5//列如:zhnglie中,第一个字符z在字符中的位置为0,那么对应密文是'm'+0+5 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string
阅读全文
posted @
2021-07-28 09:00
Bytezero!
阅读(1167)
推荐(0) 编辑
指向字符串的指针 也可以指向常量 也可以指向储存字符串的数组
摘要:1 //指向字符串的指针 也可以指向常量 也可以指向储存字符串的数组 2 3 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 8 int main () 9 { 10 //2. 11 // printf("%p\n",*
阅读全文
posted @
2021-07-28 08:59
Bytezero!
阅读(192)
推荐(0) 编辑
结构体 结构时一种构造数据类型,由若干数据项组合而成
摘要:1 //结构体 结构时一种构造数据类型,由若干数据项组合而成 2 3 //1.结构定义并不预留内存 2.结构定义一般放在程序的开始部分(头文件声名之后) 4 //3.结构定义仅用来描述结构的形式,使用结构需要声名结构变量 5 6 7 #include<stdio.h> 8 #include<stdl
阅读全文
posted @
2021-07-28 08:55
Bytezero!
阅读(115)
推荐(0) 编辑
结构体嵌套
摘要:1 //玩家 Player 2 //玩家有属性门派(种族,阵营) 3 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 8 struct Martial //门派 9 { 10 int id; //门派 id 11 cha
阅读全文
posted @
2021-07-28 08:30
Bytezero!
阅读(67)
推荐(0) 编辑
指向结构的指针 struct结构名称 *结构指针变量名
摘要://指向结构的指针 struct结构名称 *结构指针变量名 //(*结构指针变量名).成员变量名//结构指针变量->成员变量名 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 6 struct Martial //门
阅读全文
posted @
2021-07-28 08:20
Bytezero!
阅读(120)
推荐(0) 编辑
猴子吃桃问题
摘要:一只小猴子一天摘了许多桃子,第一天吃了一半,然后忍不住又吃了一个;第二天又吃了一半,再加上一个;后面每天都是这样吃。到第10天的时候,小猴子发现只有一个桃子了。问小猴子第一天共摘了多少个桃子。 1 #include<stdio.h> 2 3 int main() 4 { 5 int i = 1; 6
阅读全文
posted @
2021-07-28 08:00
Bytezero!
阅读(149)
推荐(0) 编辑