摘要:
有一个函数y=x(x<1),y=2x-1(1<=x<10),y.=3x-11(x>=10)。写一段程序,输入x,输出y值 #include<stdio.h>int main(){ float x, y; scanf("%f", &x); if (x < 1.0) y = x; else if (x 阅读全文
posted @ 2020-03-12 17:20
新生代农民工
阅读(202)
评论(0)
推荐(0)
摘要:
“从键盘输入一个小于1000的正整数,要求输出它的平方根(如平方根不是整数,则输出其整数部分)。要求在输入数据后先对其检查是否为小于1000的正数。若不是,则要求从新输入。” 第二种算法,先判断后执行 #include<stdio.h>#include<math.h>int main(){ floa 阅读全文
posted @ 2020-03-12 17:15
新生代农民工
阅读(300)
评论(0)
推荐(0)
摘要:
“从键盘输入一个小于1000的正整数,要求输出它的平方根(如平方根不是整数,则输出其整数部分)。要求在输入数据后先对其检查是否为小于1000的正数。若不是,则要求从新输入。” #include<stdio.h>#include<math.h>int main(){ float num,num1; s 阅读全文
posted @ 2020-03-12 17:12
新生代农民工
阅读(148)
评论(0)
推荐(0)
摘要:
求三位中最大的数 #include<stdio.h>int main(){ int a, b, c; scanf("%d%d%d", &a, &b, &c); if (a>b&&a>c) printf("%d", a); else if (b>a&&b>c) printf("%d", b); els 阅读全文
posted @ 2020-03-12 16:57
新生代农民工
阅读(113)
评论(0)
推荐(0)
摘要:
运输公司对用户计算运费。路程(以s表示,单位为km)越远,每千米运费越低。 标准如下: s<250 没有折扣 250≤s<500 2%折扣 500≤s<1000 5%折扣 1000≤s<2000 8%折扣 2000≤S<3000 10%折扣 3000≤s 15%折扣 设每吨每千米货物的基本运费为p, 阅读全文
posted @ 2020-03-12 16:47
新生代农民工
阅读(1547)
评论(0)
推荐(0)
摘要:
用条件语句嵌套判断是否是闰年 #include<stdio.h>int main(){ int year, test; scanf("%d", &year); if (year % 4 == 0) { if (year % 100 == 0) { if (year % 400 == 0) test 阅读全文
posted @ 2020-03-12 15:20
新生代农民工
阅读(318)
评论(0)
推荐(0)
摘要:
用switch语句处理菜单命令。在许多应用程序中,用菜单对流程进行控制,例如从键盘输入一个‘A’或‘a’字符,就会执行A操作,输入一个‘B’或‘b’字符,就会执行B操作 #include<stdio.h> void add(int a, int b){ printf("%d", a + b); // 阅读全文
posted @ 2020-03-12 14:28
新生代农民工
阅读(144)
评论(0)
推荐(0)
摘要:
输入一个字符,判断它是否为大写字母,如果是,将它转换成小写字母,如果不是不转换 三目运算符写的代码,太长时间不用三目运算符了 三目运算符表达式:表达式1?表达式2:表达式3 如果为真则输出冒号左边的否则输出右边 #include<stdio.h>int main(){ char a; scanf(" 阅读全文
posted @ 2020-03-12 14:11
新生代农民工
阅读(327)
评论(0)
推荐(0)
摘要:
判断输入的年份是否是闰年 闰年的判断条件是能被4整除但不能被100整除或能被400整除 //判断是否闰年//闰年的判断条件是能被4整除但不能被100整除或能被400整除#include<stdio.h>int main(){ int year; scanf("%d", &year); if (yea 阅读全文
posted @ 2020-03-12 14:00
新生代农民工
阅读(198)
评论(0)
推荐(0)
摘要:
之前是两个数字比较大小并排序,现在是三位数比较大小并排序 无非就三种情况a>b或a>c或b>c #include<stdio.h>int main(){ float a, b,c, t; scanf("%f%f%f", &a, &b,&c); if (a>b) { t = b; b = a; a = 阅读全文
posted @ 2020-03-12 13:52
新生代农民工
阅读(157)
评论(0)
推荐(0)