PTA|基础编程题目集|7-11

解题

考虑x不同取值y的不同计算方式

关键点

  • 选择结构
  • x不同取值计算相应的y

参考代码

#include <cstdio>
int main()
{
	float x,y;
	scanf("%f",&x);
	if(x<=15)
	{
		y=4*x/3;
	}
	else{
		y=2.5*x-17.5;
	}
	//cout<<y;
	printf("%.2f
",y);
	return 0;
}
原文地址:https://www.cnblogs.com/reaptem/p/13840716.html