最简单的C程序设计—顺序程序设计实验报告 下载本文

内容发布更新时间 : 2024/5/20 22:49:53星期一 下面是文章的全部内容请认真阅读。

choose the correct meaning; (4) to correct the typos; (5) so the child write words (ABAB, and AABB); (6) in accordance with written words; (7) the complete word, and explain the meaning of the word; (8) collocation; (9) make sentences with the word; (10) the written language as required. (C) the main sentence types (1) complete sentences; (2) write down the meaning of a sentnce or expression of thoughts and feelings; (3) write sentences as required; (4) finish malalignment of the sentence; (5) modified sentences. 2, knowledge classification (1) the common conjunctions coordinate: ... ... 一面…… ... 1, to examine the topic, identify problems associated with two 2, analysis, alternative question two is in direct proportion to the amount of the associated relationship is inversely proportional relationship. 3, and set unknown, column proportion type 4, and solutions proportion type 5, and test, wrote answer language plenary, and subject: application problem (1)--simple application problem and composite application problem review content simple application problem composite application problem answers application problem of general steps 1, and figure out meaning--through examines the, find known conditions and by seeking problem 2, and analysis number relationship--analysis known conditions Zhijian, and conditions and problem Zhijian of relationship, determine problem-solving method and problem-solving steps. 3, and column type calculation--lists formula, is out subdivisions 4, and test, and wrote answer--check, and checking, and wrote answers typical application problem 13, and subject: application problem (3)--column equation solutions application problem review content overview problem-solving steps 1, and figure out meaning, find by seeking of unknown and x said 2, and according to meaning find equivalent relationship, lists Equation 3, and solutions equation 4, and test, and wrote answers according to meaning find equivalent relationship of common method 1 , And according to common of number relationship type, established equivalent relationship 2, and according to has learn had of calculation formula, 3, and according to problem in the of focus described sentence from overall Shang determine basic of equivalent relationship 4, and using segment figure, and list method, method analysis number嘉应学院 计算机学院

实 验 报 告

课程名称 指导老师 班 级

程序设计基础

实验名称 实验时间 姓 名

实验地点 提交时间 座 号

一、实验目的和要求

(1)掌握C语言中使用最多的一种语句——赋值语句的使用方法。

(2)掌握各种类型数据的输入输出的方法,能正确使用各种格式装换符。 (3)进一步掌握编写程序的和调试程序的方法。

二、实验环境和方法

实验方法:

(一)综合运用课本所学的知识,用不同的算法实现在不同的程序功能。

(二)结合指导老师的指导,解决程序中的问题,正确解决实际中存在的异常情况,逐步改善功能。

(三)根据实验内容,编译程序。

实验环境:Windows xp Visual C++6.0

三、实验内容及过程描述

实验步骤:

① 进入Visual C++ 6.0集成环境。 ② 输入自己编好的程序。

③ 检查一遍已输入的程序是否有错(包括输入时输错的和编程中的错误),如发现有错,及时改正。

④ 进行编译和连接。如果在编译和连接过程中发现错误,频幕上会出现“报错信息”,根据提示找到出错位置和原因,加以改正。再进行编译,如此反复直到不出错为止。

⑤ 运行程序并分析运行结果是否合理。在运行是要注意当输入不同的数据时所得结果是否正确,应运行多次,分别检查在不同情况下结果是否正确。

实验内容:编译以下题目的程序并调试运行。

实验①

(1)通过下面的程序掌握各种格式装换符的正确使用方法。 ①输入以下程序:

choose the correct meaning; (4) to correct the typos; (5) so the child write words (ABAB, and AABB); (6) in accordance with written words; (7) the complete word, and explain the meaning of the word; (8) collocation; (9) make sentences with the word; (10) the written language as required. (C) the main sentence types (1) complete sentences; (2) write down the meaning of a sentence or expression of thoughts and feelings; (3) write sentences as required; (4) finish malalignment of the sentence; (5) modified sentences. 2, knowledge classification (1) the common conjunctions coordinate: ... ... 一面…… ... 1, to examine the topic, identify problems associated with two 2, analysis, alternative question two is in direct proportion to the amount of the associated relationship is inversely proportional relationship. 3, and set unknown, column proportion type 4, and solutions proportion type 5, and test, wrote answer language plenary, and subject: application problem (1)--simple application problem and composite application problem review content simple application problem composite application problem answers application problem of general steps 1, and figure out meaning--through examines the, find known conditions and by seeking problem 2, and analysis number relationship--analysis known conditions Zhijian, and conditions and problem Zhijian of relationship, determine problem-solving method and problem-solving steps. 3, and column type calculation--lists formula, is out subdivisions 4, and test, and wrote answer--check, and checking, and wrote answers typical application problem 13, and subject: application problem (3)--column equation solutions application problem review content overview problem-solving steps 1, and figure out meaning, find by seeking of unknown and x said 2, and according to meaning find equivalent relationship, lists Equation 3, and solutions equation 4, and test, and wrote answers according to meaning find equivalent relationship of common method 1 , And according to common of number relationship type, established equivalent relationship 2, and according to has learn had of calculation formula, 3, and according to problem in the of focus described sentence from overall Shang determine basic of equivalent relationship 4, and using segment figure, and list method, method analysis number #include int main() {int a,b; float d,e; char c1,c2; double f,g; long m,n;

unsigned int p,q; a=61,b=62; c1='a';c2='b'; d=3.56;e=-6.87; f=3157.;g=0.;

m=50000;n=-60000; p=32768;q=40000;

printf(\

printf(\ }

②运行程序并分析结果如图:

③在此基础上,将程序第10~14行改为 c1=a;c2=b; f=3157.;g=0.; d=f;e=g;

P=a=m=50000;q=b=n=-60000; 运行程序,分析结果如:

(二)设圆半径r=1.5,圆柱高h=3,求圆周长﹑圆面积﹑圆球表面积﹑圆球体积﹑圆柱体积。用scanf输入数据,输出计算结果,输出时要求有文字说明,取小数点后两位数字。 程序代码为: #include int main()

{float h,r,l,s,sq,vq,vz; float pi=3.;

printf(\请输入圆半径r,圆柱高h:\ scanf(\l=2*pi*r; s=r*r*pi; sq=4*pi*r*r;

vq=3.0/4.0*pi*r*r*r; vz=pi*r*r*h;

printf(\圆周长为: l=%6.2f\\n\ printf(\圆面积为: s=%6.2f\\n\

圆球表面积为:sq=%6.2f\\n\ printf(\

printf(\圆球体积为: vq=%6.2f\\n\ printf(\圆柱体积为: vz=%6.2f\\n\ return 0; }

运行结果为:

(三)计算存款利息。

有1000元,想存5年,可按以下5种方法存: ① 一次存5年期。

② 先存2年期,到期后将本息再存3年期。 ③ 先存3年期,到期后将本息再存2年期。

④ 存1年期,到期后将本息再存1年期,连续存5次。 ⑤ 存活期存款。活期利息每一季度结算一次。 2012年3月的银行存款利息如下: 1年期定期存款利息为4.16%; 2年期定期存款利息为4.71%; 3年期定期存款利息为5.45%; 5年期定期存款利息为5.85%;

活期存款利息为0.75%(活期存款每一季度结算一次利息)。 程序代码为:

#include #include int main()

{float r5,r3,r2,r1,r0,p,p1,p2,p3,p4,p5; p=1000; r5=0.0585; r3=0.0545; r2=0.0471; r1=0.0416; r0=0.0075;

p1=p*((1+r5)*5);

p2=p*(1+2*r2)*(1+3*r3); p3=p*(1+3*r3)*(1+2*r2); p4=p*pow(1+r1,5); p5=p*pow(1+r0/4,4*5);

printf(\第1种方案得到的本息和为p1=%f\\n\printf(\第2种方案得到的本息和为p2=%f\\n\printf(\第3种方案得到的本息和为p3=%f\\n\printf(\第4种方案得到的本息和为p4=%f\\n\printf(\第5种方案得到的本息和为p5=%f\\n\return 0; }