- 35
- 0
- 约 94页
- 2016-11-23 发布于北京
- 举报
2015成都信息工程学院语言系统全部答案
分类一
编写一程序P1-111.C实现以下功能
x(x只考虑整数int且必须定义为int、但F(x)完全可能超过int的表示范围)通过键盘输入(输入前给出提示Please?input?x:),然后计算并在屏幕上输出函数值。注意,图1中的括号不是而是(),编程可用素材:printf(Please?input?x:?)...。
┌ -5x+27???(x0)
F(x)=?├ 7909?????(x=0)
└ 2x-1?????(x0)
程序的运行效果应类似地如图1所示,图1中的3是从键盘输入的内容。
#include stdio.h
int main(void)
{
int x;
double y;
printf(Please input x:);
scanf(%d, x);
if (x 0)
{
y = (double) 2 * x - 1;
}
else
{
if (x == 0)
{
y = (double) 7909;
}
else
{
y = (double) - 5 * x + 27;
}
}
printf(\nF(%d) = %.0lf\n, x, y);
return 0;
}
2. P1-113已知某银行整存整取存款不同期限的年息利率分别为:3.15%期限一年,3.63%期限二年,?4.02%期限三年,4.69%期限五年,5.36%期限八年。从键盘上输入存钱的本金(以元为单位,必须定义为int且应考虑金额很大的情况)和存款期限(只考虑1,2,3,5,8),求到期时能从银行得到的利息(以元为单位,应考虑有小数,不计复利)。编程可用素材:printf(\nPlease?input?benjin,cunqi:)...、printf(\nlixi?=?...?yuan...。
程序的运行效果应类似地如图1所示,图1中的10000,8是从键盘输入的内容。
#include stdio.h
int main(void)
{
int benjin, cunqi;
double lixi;
double money;
printf(\nPlease input benjin,cunqi:);
scanf(%d,%d, benjin, cunqi);
money = benjin;
if ( cunqi == 1 )
{
lixi = money * cunqi * 3.15 / 100;
}
else
{
if ( cunqi == 2 )
{
lixi = money * cunqi * 3.63 / 100;
}
else
{
if ( cunqi == 3 )
{
lixi = money * cunqi * 4.02 / 100;
}
else
{
if ( cunqi == 5 )
{
lixi = money * cunqi * 4.69 / 100;
}
else
{
if ( cunqi == 8 )
{
lixi = money * cunqi *5.36 / 100;
}
}
}
}
}
printf(\nlixi = %.2f yuan\n, lixi);
return 0;
}
3. P1-114编写一个简单计算器程序,输入格式为:data1?op?data2。其中data1和data2是参加运算的两个数(data1、data2必须定义为int,但二者相加可能超出int能表示的范围),op为运算符,它的取值只能是+、-、*、/、%。
程序的运行效果应类似地如图1、图2、图3、图4所示,图1中的3000?+?2000、图2中的3000?%?2000、图3中的3000?%?0和图4中的3000?/?0是从键盘输入的内容。
#include stdio.h
int main( void )
{
int data1, data2;
double jieguo;
char op;
printf(\nPlease input data1 op data2:);
scanf(%d %c %d, data1, op, data2);
switch ( op )
{
case +:
jieguo = ( double ) data1 + data2;
printf(\n%d%c%d=%.0f\n, data1, op, data2, jieguo);
break;
case -:
jieguo = ( dou
您可能关注的文档
- 2015彩色电视机芯和主芯片大集合.doc
- 2015很全很实用的中英文个人简历表格.doc
- 2015很超级好个的.doc
- 2015很多朋友问我做外贸.doc
- 2015很多人都在为找客户烦.doc
- 2015很超级好.doc
- 2015德国·雷根斯堡 一个城市三个圣诞集市.doc
- 2015必修一综合练习一.doc
- 2015必修第一单元学案.doc
- 2015必修第二章 城市与城市化.doc
- 2026年国开电大管理英语4形考题库200道附参考答案【基础题】.docx
- 2026年国开电大管理英语4形考题库200道含答案【典型题】.docx
- 2026年国开电大管理英语4形考题库200道附完整答案(全优).docx
- 2026年国开电大管理英语4形考题库200道带答案(巩固).docx
- 2026年国开电大管理英语4形考题库200道附参考答案【研优卷】.docx
- 2026年国开电大管理英语4形考题库200道完整版.docx
- 2026年国开电大管理英语4形考题库200道附参考答案【完整版】.docx
- 2026年国开电大管理英语4形考题库200道附参考答案【b卷】.docx
- 2026年国开电大管理英语4形考题库200道附参考答案【满分必刷】.docx
- 2026年国开电大管理英语4形考题库200道含答案.docx
原创力文档

文档评论(0)