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) 编辑