第一次作业 中加计算机18-4班 16号

#include <stdio.h>
int main()
{
	int H;
	float weight;
	scanf("%d",&H);
	weight=(H-100)*0.9*2;
	printf("%.1f",weight);
	return 0;
}

3.4 是不是太胖了

设计思路

一,定义身高和体重

二,用scanf输入H

三,插入公式

四,用printf输出weight

五,返回

 流程图

 

 

#include <stdio.h>
int main()
{


	float x, y;
	scanf("%f", &x);
	if (x>=0&&x<=50) {
		y = 0.53 * x;
		printf("cost = %.2f", y);
	}
	else if (x > 50) {
		y = 0.53 * 50 + 0.58 * (x - 50);
		printf("cost = %.2f", y);
	}
	else {
		printf("Invalid Value!");
	}
	return 0;

}

 5.1阶梯电价

设计思路

一,定义x,y

二,用scanf输入x

三,将情况分为三种 分别用if ,else if,else表示出来

四,插入公式

五,返回

 

流程图

 

posted @ 2019-06-12 18:52  chanyoel  阅读(98)  评论(0编辑  收藏  举报