【c学习-12】
/*枚举*/
#include
void enumFunction(){
enum enum_var{"a","b",1,2};
enum{"c","d",2,1}enum_var_2;
printf("enum_var:%d\nenum_var_2:%d\n",
enum_var,enum_var_2
);
}
int main(){
enumFunction();
}
/*链表*/
#include
struct st{
struct st *next;
char name[10];
int age;
};
int main(){
//建立三个节点,向内存申请指针
struct st a,b,c,*head,*p;
//初始化这三个节点
a.name="liupeng";a.age=18;
b.name="zhansan";b.age=19;
c.name="lishi";c.age=20;
//将头指针指向起始a节点
head=&a;
//同理,逐个将前一个节点指向下一个节点
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
//对a,b,c这三个节点输出
do(){
printf("a:%c\nb:%d\nc:%c\n",
p->name,p->id,p->next);
}while(p!=NULL);
}
void structFunction(){
//定义一个结构体
struct lannuage{
char name;
int id;
char content[10];
};
//初始化一个二维结构体成员
struct lannuage la[4]={
{"c",1,"include"},
{"python",2,"import"},
{"javascript",3,"alert"},
{"php",4,"echo"}
}
//向内存申请一个指针
int *p;
//遍历这个二维结构体成员
for(p=la;pname,p->id,p->content);
}
}
int main(){
structFunction();
}
/*结构体练习*/
#include
#define X "结构体成员1和结构体成员2相等"
//定义一个结构体存放学生信息
typedef struct stu{
char name[10];
float score;
int id;
}st;
//初始化学生1-2的结构体变量
st student1;st student2;
void structFunction{
printf("请输入第一个学生的姓名和成绩:\n");
scanf("%s,%lf",&student1.name,&student1.score);
printf("请输入第二个学生的成绩和姓名:\n");
scanf("%s,%lf",&student2.name,&student2.score);
//对两个结构体进行大小判断
if(student1.score>student2.score){
//输出结构体成员大的值
printf("stu1name:%s\n,stu1score:%lf\n",
student1.name,student1.score);
}else if(student1.score
int main(){
}
/*
#include
//声明1:
struct
{
char name[10];
int age;
float money;
};
typedef struct structtest1 st1;
st1.age=18;
//声明2
struct structtest2{
char name[10];
int age;
float money;
}st2={"liupeng",18,20.0};
//声明3
struct structtest3{
char name[10];
int age;
float money;
}st3;
struct structtest3 st3;
st3.money=20.0;
int main(int argc, char const *argv[])
{
printf("st1:%s\nst2:%d\nst3:%lf\n",
st1,st2,st3
);
/*
void check(*); //声明检查函数
int i,*p1; //定义指针和计数器
p1=(int *)malloc(5 *sizeof(int));//为指针开辟一块空间
for(i=0;i
/*
void enumFunction(){
);
}*/
//enum enum_var{a=1,b=2,c=3,d=4};
enum{A=1,B=2,C=3,D=4}enum_var_2;
int main(){
//enumFunction();
printf(enum_var_2);
}
/*链表*/
/*#include
struct st{
struct st *next;
int name[10];
int age;
};;
int main(){
//建立三个节点,向内存申请指针
struct st a,b,c,*head,*p;
//初始化这三个节点
a.name=1;a.age=18;
b.name=2;b.age=19;
c.name=3;c.age=20;
//将头指针指向起始a节点
head=&a;
//同理,逐个将前一个节点指向下一个节点
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
//对a,b,c这三个节点输出
do{
printf("a:%s\nb:%d\n",p->name,p->age);
p=p->next;
}while(p!=NULL);
}
*/
/*结构体练习*/
/*#include
void structFunction(){
//定义一个结构体
struct lannuage{
char name;
int id;
char content[10];
};
//初始化一个二维结构体成员
struct lannuage la[4]={
{"c",1,"include"},
{"python",2,"import"},
{"javascript",3,"alert"},
{"php",4,"echo"}
};
//向内存申请一个指针
struct lannuage *p;
//遍历这个二维结构体成员
for(p=la;pname,p->id,p->content);
}
}
int main(){
structFunction();
}
//#define X "结构体成员1和结构体成员2相等"
//定义一个结构体存放学生信息
//void structFunction(){
/*typedef*/
/*struct stu{
char name[10];
float score;
int id;
};
int main(){
//初始化学生1-2的结构体变量
struct stu student1;struct stu student2;
printf("请输入第一个学生的姓名和成绩:\n");
scanf("%s,%lf",&student1.name,&student1.score);
printf("请输入第二个学生的成绩和姓名:\n");
scanf("%s,%lf",&student2.name,&student2.score);
//对两个结构体进行大小判断
if(student1.score>student2.score){
//输出结构体成员大的值
printf("stu1name:%s\n,stu1score:%lf\n",
student1.name,student1.score);
}else if(student1.score
【c学习-12】的更多相关文章
- JavaScript学习12 JS中定义对象的几种方式
JavaScript学习12 JS中定义对象的几种方式 JavaScript中没有类的概念,只有对象. 在JavaScript中定义对象可以采用以下几种方式: 1.基于已有对象扩充其属性和方法 2.工 ...
- ThinkPhp学习12
原文:ThinkPhp学习12 二.输出模板内容 (重点) a.display 1.display中没有参数 $this->display(); 2.可以带参数 $this ...
- JavaScript学习12 JS中定义对象的几种方式【转】
avaScript学习12 JS中定义对象的几种方式 转自: http://www.cnblogs.com/mengdd/p/3697255.html JavaScript中没有类的概念,只有对象. ...
- Asp.NetCore源码学习[1-2]:配置[Option]
Asp.NetCore源码学习[1-2]:配置[Option] 在上一篇文章中,我们知道了可以通过IConfiguration访问到注入的ConfigurationRoot,但是这样只能通过索引器IC ...
- OC学习12——字符串、日期、日历
前面主要学习了OC的基础知识,接下来将主要学习Foundation框架的一些常用类的常用方法.Foubdation框架是Cocoa编程.IOS编程的基础框架,包括代表字符串的NSString(代表字符 ...
- spring学习12 -Spring 框架模块以及面试常见问题注解等
以下为spring常见面试问题: 1.Spring 框架中都用到了哪些设计模式? Spring框架中使用到了大量的设计模式,下面列举了比较有代表性的: 代理模式—在AOP和remoting中被用的比较 ...
- 侯捷STL学习(12)--STL相关内容hash+tuple
layout: post title: 侯捷STL学习(12) date: 2017-08-01 tag: 侯捷STL --- 第四讲 STL相关的内容 Hash Function 将hash函数封装 ...
- linux 学习 12 服务管理
第十二讲 Linux服务管理 12.1 Linux服务管理-服务分类 ——Linux服务 ----RPM包默认安装的服务 ————独立的服务 ————基于xinetd服务 ----源码包安装的服务 ...
- C++学习12 友元函数和友元类
友元函数和友元类在实际开发中较少使用,想快速学习C++的读者可以跳过本节. 一个类中可以有 public.protected.private 三种属性的成员,通过对象可以访问 public 成员,只有 ...
- nginx学习12 ngx_cycle_t 和 ngx_init_cycle
在nginx在启动过程,ngx_init_cycle这个函数最初始工作.变量的初始化存储在ngx_cycle_t这个结构体中,为了深入了解这个函数都做了那些初始化工作,就化时间研究了一下.并写下来以便 ...
随机推荐
- 沙箱模式的chrome浏览器的运行
getUserMedia在chrome 47后已经不可以从非安全源访问(Insecure Origins),但测试搭建apprtc时服务器一般没有添加HTTPS安全验证,chrome就没有权限访问麦克 ...
- SharePoint 2013 - Upgrade
1. 升级到SP2013时,需要对data connection文件(UDCX文件)进行修改: 1. Mark all UDCX File (Ctrl + A) and open them. 2. F ...
- SharePoint 2010配置PDF文件全文检索
一.安装Adobe PDF 64 bit IFilter version 9合Adobe Reader 9下载地址: http://www.adobe.com/support/downloads/de ...
- 通过 PowerShell 的方式增加虚拟机终结点
关于虚拟机终结点的概念请阅读:如何设置虚拟机的终结点 本文包含以下内容(本文在名称为"pstest"的虚拟机做测试): 通过 PowerShell 的方式增加终结点 通过 Powe ...
- UML视频
https://www.bilibili.com/video/av34973179/?p=1 北京 圣思园 UML视频
- 【Leetcode】【Easy】Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...
- Selenium2学习(四)-- xpath定位
前言 在上一篇简单的介绍了用工具查看目标元素的xpath地址,工具查看比较死板,不够灵活,有时候直接复制粘贴会定位不到.这个时候就需要自己手动的去写xpath了,这一篇详细讲解xpath的一些语法. ...
- 自动驾驶self driving知识点mark
C++, algorithm, RTOS,TX2, CAN, 标准, car model,
- A full JDK must be specified
当你开发就了,你就发现,你遇到了各种奇葩的问题,结果,自己奇葩了. 背景:由于项目需要做安全恢复测试,然后,就搭一个新的库环境去测试: 配置jboss的运行jdk时,结果,蹦出个:A full JDK ...
- Kubernetes里的secret最基本的用法
Secret解决了密码.token.密钥等敏感数据的配置问题,使用Secret可以避免把这些敏感数据以明文的形式暴露到镜像或者Pod Spec中. Secret可以以Volume或者环境变量的方式使用 ...