1 / 25
文档名称:

华师大c语言实验报告——c实验报告-2-学号-姓名.doc

格式:doc   大小:292KB   页数:25页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

华师大c语言实验报告——c实验报告-2-学号-姓名.doc

上传人:buhouhui915 2018/5/14 文件大小:292 KB

下载得到文件列表

华师大c语言实验报告——c实验报告-2-学号-姓名.doc

相关文档

文档介绍

文档介绍:华东师范大学
上机实验报告
课程名称:
C语言程序设计
实验类型:
验证型
实验室名称:
*******
系别:
电子系
学号:
*******
专业:
通信工程
学生姓名:
*******
指导老师:
*******
学期:
2010年-2011第一学期
实验一嵌套结构
实验目的
熟悉选择嵌套结构、循环嵌套结构、复合嵌套结构
掌握嵌套结构的典型算法
实验内容
任务一掌握使用if…else语句
题目要求
, 修改下面程序中的4 个子函数中的代码,能按每一部分的要求得出相应的输出。修改只限于增加圆括号,和代码的缩进方式。当然代码的缩进方式对程序的执行没有影响,但可增加代码的可读性。(也可能什么修改也不要做)。
#include <>
void paint_1(int x,int y);
void paint_2(int x,int y);
void paint_3(int x,int y);
void paint_4(int x,int y)
void main()
{
int x,y;
x=5,y=8;
paint_1(x,y);
paint_2(x,y);
paint_3(x,y);
y=7;
paint_4(x,y);
}
void paint_1(int x,int y)
{
printf("\nsection 1:\n");
if (y==8)
if(x==5)
printf("@@@@@\n");
else
printf("#####\n");
printf("$$$$$\n");
printf("&&&&&\n");

}
void paint_2(int x,int y)
{
printf("\nsection 2:\n");
if (y==8)
if(x==5)
printf("@@@@@\n");
else
printf("#####\n");
printf("$$$$$\n");
printf("&&&&&\n");
}
void paint_3(int x,int y)
{
printf("\nsection 3:\n");
if (y==8)
if(x==5)
printf("@@@@@\n");
else
printf("#####\n");
printf("$$$$$\n");
printf("&&&&&\n");
}
void paint_4(int x,int y)
{
printf("\nsection 4:\n");
if (y==8)
if(x==5)
printf("@@@@@\n");
else
printf("#####\n");
printf("$$$$$\n");
printf("&&&&&\n");
}
Section 1:假定x=5,y=8,输出为:
Section 2:假定x=5,y=8,输出为:
Section 3:假定x=5,y=8,输出为:
Section 4:假定x=5,y=7,输出为:


源程序清单
列出你修改后的四段if代码
void paint_1(int x,int y)
{
printf("\nsection 1:\n");
if (y==8)
if(x==5)
printf("@@@@@\n");
else
printf("#####\n");
printf("$$$$$\n");
printf("&&&&&\n");
}
void paint_2(int x,int y)
{
printf("\nsection 2:\n");
if (y==8)
if(x==5)
printf("@@@@@\n");
else
{
printf("#####\n");
printf("$$$$$\n");
printf("&&&&&\n");
}
}
void paint_3(int x,int y)
{
printf("\nsection 3:\n");
if (y==8)
if(x==5)
printf("@@@@@\n");
else
{
printf("#####\n");
printf("$$$$$\n");
}
printf("&&&&&\n");
}
void paint_4(int x,int y)
{
printf("\nsection 4:\n");
if (y==8)
if(x==5)
printf