问下各位大神,我这个代码怎么t输入18.6-18.9,结果都是错的,输入18.6 s1应该等于1,怎么等于0 18.5结果是对的

fghg00112 fghg00112 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#define S_crane 300;
#define D_crane 400;
#define ts_Lv 50;
int t1, s1;
void title();
int Coe(int t,int s);
int ch_option();


int main() 
{

	title();//欢迎
	int t;//吨位
	int c;//价格系数
	int ch;
	float s;//跨度
	int jieguo;

	printf("请输入吨位和跨度,按回车确认。\n");
	scanf("%d", &t);//获取吨位

	printf("请输入吨位和跨度,按回车确认。\n");
	scanf("%f", &s);//获取跨度

	c = Coe(t, s);//价格系数
	ch = ch_option();
	if (ch == 111)
		jieguo = c + S_crane;
	if (ch == 121)
		jieguo = c + D_crane;
	if (ch == 221) 
	{
		jieguo = c + D_crane;
		jieguo = jieguo * 1.5;
	}
	if (ch == 211)
	{
		jieguo = c + S_crane;
		jieguo = jieguo * 1.5;
	}


	printf("%d", jieguo);



	return 0;
}



void title() 
{
	printf("**********************************************\n");
	printf("*      欢迎使用起重机检验价格查询系统        *\n");
	printf("**********************************************\n\n\n\n");
}//欢迎

int Coe(t,s) 
{
	printf("%f", s);
	if (t <= 20)
	{
		t1 = 0;
	}
	else if (t - 20 < 10)
	{
		t1 = 1;
	}
	else if (t - 20 >= 10)
	{
		t1 = (t - 20) / 10 + 1;
	}

	if (s <= 18.5)
	{
		s1 = 0;
	}
	else if (s - 18.5 <= 5)
	{
		s1 = 1;
	}
	else if (s - 18.5 > 5)
	{
		s1 = (s - 18.5) / 5 + 1;
	}
	return (t1 + s1) * ts_Lv;
}//价格系数

int ch_option()
{
	int ch_1, ch_2, ch_3;//选择
	printf("请问是年审还是监检或者单梁新装,\n年审请输入1\n监检或者单梁新装2\n");
	scanf("%d",&ch_1);
	printf("请问是单梁还是门机双梁,请输入1或2\n");
	scanf("%d", &ch_2);
	printf("请问是否为正常工作环境,正常选1,有毒高温选2,请输入1或2\n");
	scanf("%d", &ch_3);
	if(ch_1 == 1 && ch_2 ==1 && ch_3 ==1)
		return 111;
	if (ch_1 == 1 && ch_2 == 2 && ch_3 == 1)
		return 121;
	if (ch_1 == 2 && ch_2 == 1 && ch_3 == 1)
		return 211;
	if (ch_1 == 2 && ch_2 == 2 && ch_3 == 1)
		return 221;
	if (ch_1 == 1 && ch_2 == 1 && ch_3 == 2)
		return 112;
	if (ch_1 == 1 && ch_2 == 2 && ch_3 == 2)
		return 122;
	if (ch_1 == 2 && ch_2 == 1 && ch_3 == 2)
		return 212;
	if (ch_1 == 2 && ch_2 == 2 && ch_3 == 2)
		return 222;
	
}

 

s输入18.6      s1应该等于1,    怎么等于0

 

 

...全文
评论 7
收藏 已收藏
分享
返回顶部
fghg00112
C语言 70,040 成员 243,237 内容