07 2020 档案

摘要:#include <iostream> #include <string> //导入类,同时必须使用 using namespace std; //这个类是窄字节的 using namespace std; int main () { string str1 = "Hello 李明"; string 阅读全文
posted @ 2020-07-31 20:12 天子骄龙 阅读(206) 评论(0) 推荐(0) 编辑
摘要:安装:https://www.zhihu.com/question/65989308 多行注释:先CTRL+K,然后CTRL+C 取消注释: 先CTRL+K,然后CTRL+U 字体:工具 >选项-->字体和颜色 番茄助手安装:https://www.cnblogs.com/vuciao/p/1060 阅读全文
posted @ 2020-07-31 16:43 天子骄龙 阅读(1293) 评论(0) 推荐(0) 编辑
摘要:定义: namespace 名字空间名{ 名字空间成员1; 名字空间成员2; ......} 注:名字空间成员可以是全局变量、全局函数、类型、名字空间 名字空间成员的使用: :: 作用域限定操作符名字空间名::要访问的成员 #include <iostream> namespace nm1{ //定 阅读全文
posted @ 2020-07-30 08:57 天子骄龙 阅读(183) 评论(0) 推荐(0) 编辑
摘要:cout #include <iostream> //标准输入输出流 int main(){ int num=0; std::cout<<"请输入一个值:"; std::cin>>num; //用户输入一个值给变量num //c表示终端,in表示输入,>>输入操作符 std::cout<<num < 阅读全文
posted @ 2020-07-30 06:20 天子骄龙 阅读(304) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> struct student { int a; int b; int add(){ //在结构体内封装了函数 return a+b; } }; int main(){ student s={10,20}; //c++时struct 可以省略 int x=s.a 阅读全文
posted @ 2020-07-29 21:12 天子骄龙 阅读(146) 评论(0) 推荐(0) 编辑
摘要:C++标准输入、输出 名字空间 结构体 VS2017安装C++ 命名空间 向量vector string类 c++字符串 窄字节宽字节 Cstring Ansi与Unicode 操作符别名 函数的重载 在C++中用C编译函数-extern "C" {} 函数的缺省参数 函数的哑元参数 内联函数 ne 阅读全文
posted @ 2020-07-29 18:34 天子骄龙 阅读(670) 评论(0) 推荐(0) 编辑
摘要:预处理指令: #include <stdio.h> int main() { //条件编译 #if 0 printf("我是中国人\n") ; //不会被编译 #endif #if 1 printf("我喜欢中国\n") ; #endif #if 0 printf("wo\n") ; #elif 1 阅读全文
posted @ 2020-07-29 17:12 天子骄龙 阅读(144) 评论(0) 推荐(0) 编辑
摘要:fwrite() 写二进制文件 格式:size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) #include<stdio.h> int main () { FILE *fp; char str[] = "Thi 阅读全文
posted @ 2020-07-26 15:09 天子骄龙 阅读(797) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { FILE *fp=fopen("ss.txt","r"); //打开文件并创建文件指针 //实际上是由系统定义的一个结构,该结构中含有文件名、文件状态和文件当前位置等信息 //在进行读写操作之前要先打开,使用完毕要关闭 //在打开一个文 阅读全文
posted @ 2020-07-26 10:56 天子骄龙 阅读(917) 评论(0) 推荐(0) 编辑
摘要:main.c: #include <stdio.h> #include "max.h" //导入头文件--两个源文件都要导入 #include "min.h" //头文件是两个源文件的桥梁 //<>头文件直接到系统去找;""头文件先在项目中找,项目中没有再到系统中找 int main () { in 阅读全文
posted @ 2020-07-26 05:27 天子骄龙 阅读(200) 评论(0) 推荐(0) 编辑
摘要:新建-->项目--> -->选择保存文件夹(main.c文件和max.c所在的文件夹) 把自动产生的main.c关闭(不需要保存--删除) 项目-->添加-->我们需要的main.c文件和max.c文件--可以编译了 说明:在DevC++中新建一个项目,然后把几个源代码文件加入进去;对于项目,Dev 阅读全文
posted @ 2020-07-25 18:29 天子骄龙 阅读(386) 评论(0) 推荐(0) 编辑
摘要:1. 静态局部变量: #include <stdio.h> //在本地变量定义时加上static修饰符就成为静态本地变量 //当函数离开的时候,静态本地变量会继续存在并保持其值 //静态本地变量的初始化只会在第一次进入这个函数时做,以后进入函数时会保持上次离开时的值 //静态本地变量的实质是特殊的全 阅读全文
posted @ 2020-07-25 09:45 天子骄龙 阅读(1424) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int gall=12;//main函数之外定义的变量为全局变量 int f(void){ ////main函数之外定义函数的作用域为全局 printf("%s\n",__func__); //__func__ 返回当前函数的名称 int gall=1; //在 阅读全文
posted @ 2020-07-25 09:21 天子骄龙 阅读(136) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> //联合体 //联合体union是一个能在同一个存储空间存储不同类型数据的类型,联合体所占的内存长度等于其最长成员的长度,也有叫做共用体 //联合体虽然可以有多个成员,但同一时间只能存放其中一种,对于联合体来讲最基本的原则是,一次只操作一个成员变量,如果这个变量 阅读全文
posted @ 2020-07-25 07:49 天子骄龙 阅读(102) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> //给结构体起个新名字stu typedef struct student { char name[50]; int age; int achievement; } stu; //student 可以不要 //新名字的好处,使用时简洁 int main () { 阅读全文
posted @ 2020-07-24 22:36 天子骄龙 阅读(224) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main () { enum DAY{MON=1, TUE, WED, THU, FRI, SAT, SUN};//声明枚举数据类型 //枚举格式:enum 枚举名 {枚举元素1,枚举元素2,……}; //注意:第一个枚举成员的默认值为整型的 0,后续枚 阅读全文
posted @ 2020-07-23 16:37 天子骄龙 阅读(154) 评论(0) 推荐(0) 编辑
摘要:安装:pip install vpython -i https://mirrors.aliyun.com/pypi/simple vpython 阅读全文
posted @ 2020-07-22 18:49 天子骄龙 阅读(364) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> #include <stdlib.h> int main() { char a[]={'H','e','l','l','o'}; //定义了一个字符数组 char b[]={'H','e','l','l','o','\0'}; //定义了一个字符串 //字符串以 阅读全文
posted @ 2020-07-21 12:36 天子骄龙 阅读(170) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> #include <stdlib.h> int main() { int num=10; int *a; a=(int *)malloc(num*sizeof(int));//分配所需的内存空间,并返回一个指向它的指针(Void*类型) //malloc的返回值 阅读全文
posted @ 2020-07-21 08:07 天子骄龙 阅读(767) 评论(0) 推荐(1) 编辑
摘要:一个{}为块,在哪个块定义的变量,作用域就在这个块内 阅读全文
posted @ 2020-07-19 12:42 天子骄龙 阅读(107) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int a=0,b=320; short s=0; //数据强制转换的格式:(类型)值 a=(int)102.3; //把浮点数转换成int printf("%d\n",a); s=(short)b; //把int转换成short re 阅读全文
posted @ 2020-07-18 20:19 天子骄龙 阅读(434) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int n=2345,a=10,b=20; a=sizeof(int); //判断数据类型占用的字节数 printf("%d\n",a); a=sizeof(n); //判断一个变量占用的字节数 printf("%d\n",a); pr 阅读全文
posted @ 2020-07-18 11:09 天子骄龙 阅读(394) 评论(0) 推荐(0) 编辑
摘要:break 跳出一层循环 continue 结束本次循环,继续下次循环 阅读全文
posted @ 2020-07-18 09:09 天子骄龙 阅读(148) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int n=0; for (n=0;n<10;n++){ printf("%d",n); } return 0; } 阅读全文
posted @ 2020-07-18 09:00 天子骄龙 阅读(153) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int a=4693497862,n=0; a=a/10; while(a>1){ //先判断后执行 n++; a=a/10; } printf("%d位数",n); return 0; } #include <stdio.h> int 阅读全文
posted @ 2020-07-18 08:24 天子骄龙 阅读(155) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int a=4; switch (a){ case 1: printf("1") ; break; //跳出一层循环和switch结构 //break语句对if-else的条件语句不起作用;在多层循环中, 一个break语句只向外跳一层 阅读全文
posted @ 2020-07-17 22:20 天子骄龙 阅读(211) 评论(0) 推荐(0) 编辑
摘要:// 单行注释 /* */ 多行注释 阅读全文
posted @ 2020-07-17 20:02 天子骄龙 阅读(210) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int a=5; if (a<5){ printf("a值小于5"); } else{ printf("a值大于等于5"); } return 0; } 阅读全文
posted @ 2020-07-17 19:57 天子骄龙 阅读(156) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int a=10,b=3; printf("%d\n",a/b*100);//注意:两个整数相除返回值还是整数,小数部分直接删除了 //返回值:300 printf("%f\n",10.0/3); printf("%lf",30/3.1 阅读全文
posted @ 2020-07-17 08:09 天子骄龙 阅读(358) 评论(0) 推荐(0) 编辑
摘要:#include <stdio.h> int main() { int amount=100; int price=0; //定义了一个int类型的变量,初始值是0 printf("请输入金额(元):"); scanf("%d",&price); //通过键盘给程序中的变量赋值 //参数1:输入控制 阅读全文
posted @ 2020-07-16 23:20 天子骄龙 阅读(611) 评论(0) 推荐(0) 编辑
摘要:5.11版本下载:链接:https://pan.baidu.com/s/1YUYHZmhTJoIdHL_R2pY1Mg 提取码:6666 安装:看 https://www.cnblogs.com/HGNET/p/11741600.html 注意调试的设置 改变字体大小: 工具 >编辑器选项 >显示 阅读全文
posted @ 2020-07-16 22:12 天子骄龙 阅读(2277) 评论(0) 推荐(0) 编辑
摘要:Pygame 使用 Color 类表示 RGBA 颜色值,每个颜色值的取值范围是 0 ~ 255。允许通过基本的算术运算创造新的颜色值,支持转换为其他颜色空间,例如 HSV 或 HSL,并让你调整单个颜色通道。当没有给出 alpha 的值是,默认是 255(不透明) “RGB值”可以是一个颜色名,一 阅读全文
posted @ 2020-07-15 19:52 天子骄龙 阅读(1117) 评论(0) 推荐(0) 编辑
摘要:原文出处:https://www.cnblogs.com/msxh/p/5027688.html 我稍作修改 import pygame,os,random pygame.init() os.environ['SDL_VIDEO_CENTERED'] = '1' screen = pygame.di 阅读全文
posted @ 2020-07-14 14:21 天子骄龙 阅读(477) 评论(0) 推荐(0) 编辑
摘要:这个模块包含了 Pygame 定义的各种常量 from pygame.locals import * 将所有的 Pygame 常量导入 阅读全文
posted @ 2020-07-10 08:46 天子骄龙 阅读(1498) 评论(0) 推荐(0) 编辑
摘要:用于快速实现完美的碰撞检测,Mask 可以精确到 1 个像素级别的判断 import pygame pygame.init() screen = pygame.display.set_mode((500, 400)) pygame.display.set_caption("遮罩") tu = pyg 阅读全文
posted @ 2020-07-09 12:42 天子骄龙 阅读(1712) 评论(0) 推荐(0) 编辑
摘要:1.两个精灵之间的矩形检测 import pygame import random BLACK = ( 0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) class Block(pygame.sprite.Sprite): def __init__ 阅读全文
posted @ 2020-07-08 13:08 天子骄龙 阅读(3171) 评论(0) 推荐(0) 编辑
摘要:Group类,它只存储sprite对象 import pygame pygame.init() screen = pygame.display.set_mode((960, 800)) pygame.display.set_caption("pygame.sprite.Group") class s 阅读全文
posted @ 2020-07-07 12:37 天子骄龙 阅读(3752) 评论(0) 推荐(0) 编辑
摘要:在pygame.sprite模块里面包含了一个名为Sprite类,他是pygame本身自带的一个精灵 在pygame里,sprite通常是一个二维的图片。比如一辆汽车、一个狐狸、一条小狗等 使用sprites的主要好处是我们可以把游戏里的所有角色在一个组里做统一处理。我们可以同时渲染、移动他们。我们 阅读全文
posted @ 2020-07-06 15:32 天子骄龙 阅读(650) 评论(0) 推荐(0) 编辑
摘要:import pygame import time pygame.init() screen = pygame.display.set_mode((200, 100)) bb=pygame.mixer.Sound('酒醉的蝴蝶.ogg') a=pygame.mixer.get_num_channel 阅读全文
posted @ 2020-07-03 10:33 天子骄龙 阅读(798) 评论(0) 推荐(0) 编辑
摘要:import pygame import time pygame.init() screen = pygame.display.set_mode((200, 100)) bb=pygame.mixer.Sound('酒醉的蝴蝶.ogg') #载入音乐并返回其对象 #【不能载入mp3】 #可以从OGG 阅读全文
posted @ 2020-07-03 08:56 天子骄龙 阅读(1982) 评论(0) 推荐(0) 编辑
摘要:import pygame pygame.init() screen = pygame.display.set_mode((960, 600)) pygame.display.set_caption("图像变换") img = pygame.image.load('马.jpg') clock = p 阅读全文
posted @ 2020-07-02 11:54 天子骄龙 阅读(1664) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示