《东莞理工学院C语言程序设计作业实验二》由会员分享,可在线阅读,更多相关《东莞理工学院C语言程序设计作业实验二(12页珍藏版)》请在人人文库网上搜索。
1、C语言程序设计作业实验二2.1/* 程序功能:输入两个整数a和b,求两数之和,两数之差的绝对值。*/* 提示:除在指定位置添加语句外,请不要改动程序中的其他内容。 */#include #include void main( )int a, b, sum, diff;scanf(%d%d, &a, &b);/请在两条星线之间填入相应的代码,求两数之和,两数之差的绝对值。/*/sum=a+b;diff=abs(a-b);/*/printf(a+b的和等于%dn, sum);printf(a-b的差的绝对值等于%dn, diff);2.2/* 程序功能:输入存款金额money、存期year和年利率。
2、rate,根据公式计算到期时的本息和sum,输出结果保存两位小数。*/* 提示:除在指定位置添加语句外,请不要改动程序中的其他内容。 */请在两条星线之间填入相应的代码,包含数学库函数/*/#include/*/#include void main( )int money,year;double rate,sum;/请在两条星线之间填入相应的代码/输入存款金额money、存期year和年利率rate,根据公式计算本息和sum/*/printf(Enter money:,money);scanf(%d,&money);printf(Enter year:,year);scanf(%d,&year。
3、);printf(Enter rate:,rate);scanf(%lf,&rate);sum=money*pow(1+rate,year);/*/printf(本息和等于%.2fn, sum);2.3/程序功能:输入x的值,计算并输出分段函数的值(保留2 位小数)。/提示:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include #include void main( )double x, y;scanf(%lf, &x);/请在两条星线之间填入相应的代码,计算分段函数y的值/*/if(x#include void main( )double x, y;scanf(%lf, &。
4、x);/请在两条星线之间填入相应的代码,计算分段函数y的值/*/if(xvoid main( )int fm,flag,i,n;double item,sum;printf(请输入一个正整数:);scanf(%d, &n);/请在两条星线之间填入相应的代码/使用for循环结构计算1-1/3+1/5-1/7+.的前n项之和/*/sum=0;flag=1;fm=1;for(i=1;ivoid main( )int fz,fm,flag,i,n,temp;double item,sum;printf(请输入一个正整数:);scanf(%d, &n);/请在两条星线之间填入相应的代码/使用for循环结。
5、构计算1-1/2+2/3-3/5+.的前n项之和/*/sum=0;flag=1;fm=1;temp=0;fz=1;for(i=1;ivoid main( )int i,n;double item,sum;double fact(int n); /* 声明函数fact */printf(请输入一个正整数:);scanf(%d, &n);/请在两条星线之间填入相应的代码/使用for循环语句计算1!+2!+.+n!, 要求调用函数fact(n)求n!/*/sum=0;for(i=1;ivoid main( )int i,n;double x,sum;double power(double x,int。
6、 n); /* 声明函数power */printf(请输入一个正整数:);scanf(%d, &n);printf(请输入一个实数:);scanf(%lf, &x);/请在两条星线之间填入相应的代码/使用for循环语句计算幂函数的累加和, 要求调用函数power(x,n)求xn/*/sum=0;for(i=1;iint main()int i,n,flag;double x,sum;double power(double x,int n);double fact(int n);printf(请输入一个正整数n:);scanf(%d,&n);printf(请输入一个实数x:);scanf(%l。
7、f,&x);if(x=0)sum=0;flag=1;for(i=1;i=n;i+) sum=sum+flag*power(x,i)/fact(i);flag=-flag;elsesum=0;flag=1;for(i=1;i=n;i+) sum=sum+flag*fact(i)/power(x,i);flag=-flag;printf(x=%.2lf,n=%d,sum=%.2lfn,x,n,sum);double power(double x,int n)int i; double pow;pow=1;for(i=1;i=n;i+) pow=pow*x;return pow;double fac。
8、t(int n)int i;double product;product=1;for(i=1;i=n;i+) product=product*i;return product;coefficient not greater than 1.3; High efficiency: control 1 hour travel time between any two points within the various groups within the area up to half an hour, 1-hour access to the airport, 45min reached the c。
9、itys main traffic hub, external highway for half an hour with the main channels connecting bus 1.5 hours between any two groups of core areas; Intensive: 2030 transit share rate of around 35%, 2050 bus sharing rate of 45% per cent. 3rd chapter, Yibin city, traffic situation and General . 3.1.1 city 。
10、traffic status 1, external transport passenger and cargo traffic in Yibin city, traffic at the present main railway, highway, waterway and air four modes of passenger and freight transport, thereand cultural heritage, highlighting the cultural taste and shape characteristics of the city in Yibin. Ac。
11、cording to forecasts, vision 2050 population will reach 2.1 million people in the center of Yibin city, urban land is around 210km2. Figure 2.6-1 2050 figure 2.7 land use planning in the Center City, Yibin city development requires the development of bus rapid transit construction and socio-economic。
12、 development trends, Yibin city coordination, supporting urban space layout and infrastructure networks, transport organized, internal and external traffic hub smoothly linking, realizing sustainable development of Yibin city integrated transportation system. Concrete can be summarized as, accessible, efficient, intensive and sustainable. Accessibility: Central built-up area road network density of about 7.0km/km2; bus line density of 3-4 km/km2, bus transfer。