Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
Lab008
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
CS Lab Group
实验项目模板
实验模板
Lab008
提交
c1e058a6
提交
c1e058a6
12月 13, 2018
创建
作者:
赵鹏翀
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init template
上级
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
154 行增加
和
0 行删除
+154
-0
.gitignore
.gitignore
+2
-0
Lab008.csproj
Lab008.csproj
+31
-0
Lab008.puo
Lab008.puo
+0
-0
console.c
console.c
+103
-0
console.h
console.h
+18
-0
没有找到文件。
.gitignore
0 → 100644
浏览文件 @
c1e058a6
/Debug
/Release
Lab008.csproj
0 → 100644
浏览文件 @
c1e058a6
<?xml version="1.0" encoding="gb2312"?>
<ASMProject
Version=
"1.00"
Name=
"Lab008"
TemplatePath=
"console(c)\Project"
ProjectID=
"3a728c50-628c-4bc7-ade2-e5ae2de5cece"
IsSubmitWork=
"0"
>
<Configurations>
<Configuration
Name=
"Debug"
DebuggerFlavor=
"0"
>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"_DEBUG"
GenerateDebugInformation=
"-1"
LanguageStandard=
"c99"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"GCCLinkerTool"
/>
<Tool
Name=
"PostBuildEventTool"
/>
</Configuration>
<Configuration
Name=
"Release"
DebuggerFlavor=
"0"
>
<Tool
Name=
"PreBuildEventTool"
/>
<Tool
Name=
"CustomBuildTool"
/>
<Tool
Name=
"GCCCompilerTool"
PreprocessorDefinitions=
"NDEBUG"
LanguageStandard=
"c99"
/>
<Tool
Name=
"PreLinkEventTool"
/>
<Tool
Name=
"GCCLinkerTool"
StripDebugInfo=
"-1"
/>
<Tool
Name=
"PostBuildEventTool"
/>
</Configuration>
</Configurations>
<Files>
<Filter
Name=
"ͷļ"
Filter=
"h;hpp;hxx"
>
<File
RelativePath=
".\console.h"
>
</File>
</Filter>
<Filter
Name=
"Դļ"
Filter=
"cpp;c;cc;cxx"
>
<File
RelativePath=
".\console.c"
>
</File>
</Filter>
</Files>
</ASMProject>
Lab008.puo
0 → 100644
浏览文件 @
c1e058a6
添加文件
console.c
0 → 100644
浏览文件 @
c1e058a6
#include "console.h"
#include <stdlib.h>
int
main
(
int
argc
,
char
*
argv
[])
{
// C语言程序的机器级表示
case1
();
// 过程调用
case2
();
// 选择语句if
case3
();
// for循环结构
// 复杂数据类型的分配和访问
case4
();
// 数组
case5
();
// 指针
case6
();
// 结构体
case7
();
// 联合体
return
0
;
}
int
sum
(
int
i
,
int
j
)
{
int
k
=
i
+
j
;
// 加法
return
k
;
}
void
case1
()
{
int
i
=
sum
(
1
,
2
);
}
void
case2
()
{
int
x
,
y
;
// if语句
if
(
x
>
y
)
y
++
;
else
x
--
;
}
void
case3
()
{
// for循环
int
i
,
sum
=
0
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
sum
=
sum
+
i
;
}
}
void
case4
()
{
// 数组
int
i
=
1
;
int
a
[
4
];
a
[
0
]
=
6
;
a
[
1
]
=
7
;
a
[
i
+
1
]
=
8
;
}
typedef
struct
_TreeNode
{
int
val
;
struct
_TreeNode
*
lchild
,
*
rchild
;
}
TreeNode
;
void
case5
()
{
// 指针
TreeNode
*
p
=
(
TreeNode
*
)
malloc
(
sizeof
(
TreeNode
));
p
->
lchild
=
p
;
p
=
p
->
rchild
;
}
// #pragma pack(1) // 通知编译器按照单个字节方式对齐下列结构体中的成员
typedef
struct
_Rec
{
int
i
;
char
c
;
int
j
;
}
Rec
;
#pragma pack() // 恢复默认对齐方式
void
case6
()
{
Rec
x
;
// 结构体
x
.
j
=
1
;
x
.
c
=
x
.
j
;
x
.
i
=
x
.
j
;
}
union
var
{
char
c
[
4
];
int
i
;
};
void
case7
()
{
// 联合体
union
var
data
;
data
.
c
[
0
]
=
0x04
;
// 在内存中的内容是由低到高04 03 02 11
data
.
c
[
1
]
=
0x03
;
data
.
c
[
2
]
=
0x02
;
data
.
c
[
3
]
=
0x11
;
printf
(
"%x
\n
"
,
data
.
i
);
// 输出结果是11020304,所以可以看出是小端模式
}
console.h
0 → 100644
浏览文件 @
c1e058a6
#ifndef _CONSOLE_H_
#define _CONSOLE_H_
#include <stdio.h>
/* TODO: 在此处引用程序需要的其他头文件 */
void
case1
();
void
case2
();
void
case3
();
void
case4
();
void
case5
();
void
case6
();
void
case7
();
int
add
(
int
i
,
int
j
);
#endif
/* _CONSOLE_H_ */
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论