int main() { float f=0, fee=0; int d=0,dp=0; printf(\ scanf(\ if ((f>0)&&(f<10)) {
if (f <= 3 && d < 5) {
fee = 8;
printf(\ }
if (f<10&&d>=5) {
dp=d/5;
fee=(f-3)*2+8+2 * dp; printf(\ } } if (f >= 10 && d >= 5) { dp = d / 5; fee = (f - 10) * 3 + 22 + 2 * dp; printf(\ } if (f >= 10 && d < 5) { fee = (f - 10) * 3 + 22; printf(\ } return 0; }
3数据区间判断(6分) 题目内容:
从键盘输入一个int型的正整数n(已知:0 程序运行结果示例1: Please enter the number: 2563↙ 2563: 1000-9999 程序运行结果示例2: Please enter the number: 156↙ 156: 100-999 程序运行结果示例3: Please enter the number: 36↙ 36: 10-99 程序运行结果示例4: Please enter the number: 3↙ 3: 0-9 程序运行结果示例5: Please enter the number: 10923↙ error! 输入提示信息:\输入格式: \输出格式: 输出的区间判断: \\\\ 输入错误提示信息:\ 为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。 #include printf(\ else if (x>=1000&&x<=9999) printf(\ else if (x>=10&&x<=99) printf(\ else if (x>=100&&x<=999) } printf(\else printf(\return 0; 4计算一元二次方程的根v2.0(4分) 题目内容: 根据下面给出的求根公式,计算并输出一元二次方程 的两个实根,要求精确到小 数点后4位。其中a,b,c的值由用户从键盘输入。如果用户输入的系数不满足求实根的要求,输出错误提示 \。程序中所有的数据类型均为float。 程序运行结果示例1: Please enter the coefficients a,b,c: 1,2,1↙ x1=-1.0000, x2=-1.0000 程序运行结果示例2: Please enter the coefficients a,b,c: 2,6,1↙ x1=-0.1771, x2=-2.8229 程序运行结果示例3: Please enter the coefficients a,b,c: 2,1,6↙ error! 输入提示信息:\输入格式: \输出格式: 输出格式:\ 如果输入的系数不满足求实根的要求,输出错误提示信息:\ 为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。 #include scanf(\ m=b*b-4*a*c; if (m<0){ printf(\ } else{ x1 = (-b + sqrt(m))/(2 * a); x2 = (-b - sqrt(m))/(2 * a); printf(\ } return 0; } 第5周——周而复始的循环之道 16位密码输入检测(4分) 题目内容: 从键盘输入6位仅由数字0~9组成的密码。用户每输入一个密码并按回车键后,程序给出判断:如果是数字,则原样输出该数字,并提示用户目前已经输入了几位密码,同时继续输入下一位密码;否则,程序提示\,并让用户继续输入下一位密码。直到用户输入的密码全部是数字为止。 以下为程序的运行结果示例: Input your password: 1↙ 1, you have enter 1-bits number 6↙ 6, you have enter 2-bits number a↙ error d↙ error 4↙ 4, you have enter 3-bits number 6↙ 6, you have enter 4-bits number 8↙ 8, you have enter 5-bits number 2↙ 2, you have enter 6-bits number 输入提示信息:\输入格式: \ 输出格式: 如果输入的是数字,输出格式为:\如果输入的不是数字,输出提示信息:\ 为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。 #include printf(\ while(i<6) { scanf(\ if (a>=48&&a<=57) { printf(\ } else { printf(\ } getchar(); } return 0; } 2判断一个整型数据有几位v1.0(4分) 题目内容: 从键盘输入一个整型数据(int型),编写程序判断该整数共有几位。例如,从键盘输入整数16644,该整数共有5位。 程序运行结果示例1: Please enter the number: 21125↙ 21125: 5 bits 程序运行结果示例2: Please enter the number: -12234↙ -12234: 5 bits 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库中国大学C语言程序题(2)在线全文阅读。
相关推荐: