C
codeEast
这个作者很懒,什么都没留下…
展开
-
C语言之结构体
#include<stdio.h>struct weapon{ char name[20]; int atk; int price;};//记住加逗号;/*第二种定义方:在}后加上weapon_1;struct weapon{ char name[20]; int atk; int price;}weapon_1;*/原创 2017-08-03 22:55:24 · 169 阅读 · 0 评论 -
C语言之共用体(联合体)
#include<stdio.h>struct data1{ int a;//偏移0 char b;//偏移量:某个成员的实际地址相对于结构体首地址的距离 偏移为4 为char 的4 倍 int c;//偏移为5,不是4的整数倍 字节对齐 系统填充3个字节 故偏移量为8 加上4 结构体长度为12 //结构体大小:等于结构体最后一个成员原创 2017-08-04 10:57:40 · 870 阅读 · 0 评论 -
c语言静态链表基础
静态链表所有的结点都是在程序中定义的,而不是临时开辟的staticLink.c#include<stdio.h>struct weapon{ int price; int atk; struct weapon *next;};int main(){ struct weapon a,b,c,*head; a.price=100; a.atk=100原创 2017-08-04 11:25:19 · 294 阅读 · 1 评论 -
c语言动态链表基础
dtLink.c#include<stdio.h>#include<malloc.h>struct weapon{ int price; int atk; struct weapon *next;}; struct weapon *create(){ //尾插法创建链表 返回值是链表的头指针 struct weapon *head; str原创 2017-08-04 12:25:33 · 409 阅读 · 0 评论 -
c语言位运算
#include<stdio.h>int main(){ //& 位与 | 位或 ^ 异或 ~按位取反 << 左移 >>右移 int a=4;// 00000000 00000000 00000000 00000100 补码参与运算 int b=7;// 00000000 00000000 00000000 00000111 // 000原创 2017-08-04 14:16:10 · 238 阅读 · 0 评论 -
c语言打印九九乘法表
#include <stdio.h>int main() { // 定义相乘数字i,j以及结果result int i, j, result; for(i=9;i>=1;i--)//外层循环从9开始,每次循环减一 { for(j=1;j<=i;j++){//内层循环从1开始,每次加1 result=i*j;原创 2017-08-04 15:45:24 · 582 阅读 · 0 评论 -
c语言之单链表
#define OVERFLOW -1;#define OK 1;#define ERROR 0;#define FLASE 0;#define TRUE 1;#include<stdio.h>#include<stdlib.h>#include<malloc.h>typedef int Status;typedef int ElemType;typedef struct LNod原创 2017-07-28 20:18:19 · 221 阅读 · 0 评论 -
C基础
#include<stdio.h>int main(int argc,char *argv){ int t=4; printf("%lu\n",sizeof(t--)); printf("%lu\n",sizeof("ab c\nt\012\xa1*2"));//格式输出无符号长整数 4 11}/***********************************原创 2017-09-21 08:16:53 · 150 阅读 · 0 评论