华师大C语言实验报告——C实验报告2学号姓名

  • 格式:doc
  • 大小:59.50 KB
  • 文档页数:18
{
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,输出为:
华东师范大学
上机实验报告
课程名称:
C语言程序设计
实验类型:
验证型
实验室名称:
*******
系别:
电子系
学号:
*******
专业:
通信工程
学生姓名:
*******
指导老师:
*******
学期:
2010年-2011第一学期
实验一
实验目的
(1)熟悉选择嵌套结构、循环嵌套结构、复合嵌套结构Βιβλιοθήκη (2)掌握嵌套结构的典型算法
{ double number;
//输入一个工资
printf("number:");
scanf("%lf",&number);
//调用calTax求解应缴个人所得税
double calTaxt(double number);
//输出结果
printf("tax=%.2f\n", calTaxt(number));
return 0;
}
double calTaxt(double number)
{//计算应缴个人所得税
int rate;
if(number<=850)
rate=0;
else
if(number<=1350)
rate=5;
else
if(number<=2850)
rate=10;
else
if(number<=5850)
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);
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");
rate=15;
else
rate=20;
return rate*(number-850)/100;
}
运行结果窗口
3.测试用例设计
1)number=750;
tax=0.00;
2)number=850;
tax=0.00;
{//计算应缴个人所得税
}
2.编写计算应缴个人所得税函数:double calTaxt(double number),返回应缴个人所得税。在main函数中验证函数calTaxt的正确性。
源程序清单:
#include <stdio.h>
double calTaxt(double number);
int main()
printf("&&&&&\n");
}
任务二
P56习题3第2题
1.打开程序文件ex02_02.cpp
#include <stdio.h>
double calTaxt(double number);
int main()
{
//输入一个工资
//调用calTax求解应缴个人所得税
//输出结果
}
double calTaxt(double number)
}
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("&&&&&\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");
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");
Section 3:假定x=5,y=8,输出为:
Section 4:假定x=5,y=7,输出为:
2.源程序清单
列出你修改后的四段if代码
void paint_1(int x,int y)
{
printf("\nsection 1:\n");
if (y==8)
if(x==5)
printf("@@@@@\n");
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");
实验内容
任务一
1.题目要求
打开程序文件ex02_02.cpp,修改下面程序中的4个子函数中的代码 ,能按每一部分的要求得出相应的输出。修改只限于增加圆括号,和代码的缩进方式。当然代码的缩进方式对程序的执行没有影响,但可增加代码的可读性。(也可能什么修改也不要做)。
#include <stdio.h>
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
{