实验1-C语言实验报告

C语言程序设计(A)

(20xx-20xx-1)

实验报告1

教学班级: 机械094 学号: 01 姓名:谭亮恩

课程教师: 曹瑛 实验辅导教师: 曹瑛

P6-4:/*P6-4 表示第6页 第四题*/

int main ()

{

float r,s;

r=15.5;

s=2*3.14*r;

printf("r=%4.2f,s=%f", r, s);

return 0;

}

结果是:r=15.5 s=97.34

P32-3-1: /*P32-3-1 表示第6页 第四题 第一小题*/ #include <stdio.h>

int main()

{

printf("this\tis\tc\bC\tprogram.\rT\n" );

return 0;

}

结果是: This is C program.

P32-3-2: /*P32-3-2 表示第6页 第四题 第二小题*/ #include <stdio.h>

int main()

{

printf("*\\abd\bc\t\r\\*ABCD\105\x46*\\" );

return 0;

}

结果是: \*ABCDEF*\

 

第二篇:C语言实验报告

实验报告

指导教师 曾宪华 实验时间: 20xx年x月x日学院 计算机 专业 智能与科学类

班级 0401116 学号 20xx2120xx 姓名 罗仁飞 实验室 s319 实验题目:1.习题6.15

2.计算椭圆面积

实验目的:1加深对讲授内容的理解

2了解和熟悉C语言程序开发的环境

3学会上机调试程序

实验要求: 准备上机所需的程序

实验主要步骤:

1.# include<stdio.h>

struct student

{

int num;

float score;

}stu[15];

void main()

{

int i,j,m;struct student stu[15];float t;

printf("请输入学号及成绩:");

for(i=0;i<15;i++)

scanf("%d %f",&stu[i].num,&stu[i].score);

for(i=0;i<15;i++)

for(j=0;j<13-i;j++)

{

if(stu[j].score>stu[j+1].score)

{

t=stu[j].score;m=stu[j].num;

stu[j].score=stu[j+1].score;stu[j].num=stu[j+1].num; stu[j+1].score=t;stu[j+1].num=m;

}

}

printf("%d %f",stu[0].num,stu[0].score);

}

2. # include<stdio.h>

# include<math.h>

struct ellipse

{

struct point

{

float x;

float y;

}p1,p2;

float a;

float b;

};

typedef struct ellipse ell;

void main()

{

ell e;float s;

printf("请输入左上角顶点坐标:"); scanf("%f,%f",&e.p2.x,&e.p1.y); printf("请输入右下角顶点坐标:"); scanf("%f,%f",&e.p2.x,&e.p1.y); e.a=(e.p1.y-e.p2.y)/2;

e.b=(e.p1.x-e.p2.x)/2;

s=3*e.a*e.b;

printf("%f",s);

}

实验结果:正确输出结果

心得体会:必须正确考虑算法,防止逻辑错误。

相关推荐