我刚刚回到编程,请帮助修复此代码。 [英] I have just returned to programming , please help fix this code.

查看:110
本文介绍了我刚刚回到编程,请帮助修复此代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿那里,我刚刚开始我的第一个项目多年,我遇到了问题。基本上我开始编写一个建筑估算应用程序。

我为ht和len输入1,但它仍然显示为229332。

这是代码:



  #include   <   stdio.h  >  


int no_brick = 0 ,no_block,no_hours,bl_price = 15 ,br_price = 400 ,day_w = 20 ,b_chce = 0 ,mm_sqr,m_chce;


int main()

{

printf(< span class =code-string> 您好,我将指导您完成您想要执行的工作。\ n \\ n。);
printf( 正因为如此,您知道这只会估算人工成本和所需的\ umaterials数量。如果您决定继续进行构建,我们将讨论所需的材料,并在继续施工之前为您提供完整的价格。\ n \ n);
printf( 现在,您要构建什么\ n \\ n请输入一个数字正确的选择如下:\ n 1花园或挡土墙\\\
2扩展\ n 3 House \ n 4补救工作\ n \\ n:
);

scanf( %i,& b_chce);

system( cls);

int len;
int ht;
int mtr_sqr;

switch (b_chce)
{
case 1
printf( 让您的价格为您的价格墙!\ n \\ n你需要以下东西:\\\
Measuring tape\\\
Pen and paper\\\
\\\
);

printf( 现在,只需通过测量每个测量周长来测量墙的长度如此开心。现在我们需要你想要的高度,高度必须是75毫米的倍数才能按照砖砌工作。\ n \\ n跨度>);

printf( 现在你可以用米输入长度: );
scanf( %i,& len);

printf( \ n \ n现在输入高度也以米为单位请: );
scanf( %i,& ht);

printf( \ n你想要用石头或砖砌成的墙吗?: );
scanf( %i,& m_chce);

printf( no of brick =%i,& ht );

printf( no of brick =%i,& len );

mtr_sqr = len * ht;

printf( no of brick =%i,& mtr_sqr );

no_brick = mtr_sqr * 59 ;

printf( no of brick =%i,& no_brick );

break ;


case 2
printf(< span class =code-string>
让您的分机价格!);
break ;

case 3
printf( 让你的房子定价!);
break ;

case 4
printf( 让我们试试你的价格!);
break ;

默认
printf( 请输入正确的选择,谢谢。);
}

getch();
return 0 ;
}

解决方案

我认为你不想要& in

 printf(no of brick =%i,< big>&< / big> ht);< br /> 

和其他行


Hey there, I just started my first program in years and i have a problem. Basically I started writing a construction estimation app.
i enter 1 for ht and len but it keeps showing both as "229332".
Here is the code:

#include<stdio.h>


int no_brick = 0, no_block, no_hours, bl_price = 15, br_price = 400, day_w = 20, b_chce = 0, mm_sqr, m_chce;


int main()

{
	
	printf("Hi, I am going to guide you through estimating the work you want carried out. \n\n");
	printf("Just so you know this will only estimate labour costs and the amount of \nmaterials needed.\n\nIf you decide to go ahead with your build we will discuss materials wanted and \ngive you a complete price before going ahead with construction.\n\n");	
	printf("Now , what is it you want to built \n\nPlease enter a number for the correct choice as follows:\n 1 Garden or retaining wall \n 2 Extension \n 3 House \n 4 Remedial work \n\n :");
	
		scanf("%i", &b_chce);
	
    system("cls");
    
    int len;
    int ht;
    int mtr_sqr;

	switch(b_chce)
	{
		case 1 : 
			printf("Lets price your wall!\n\nYou will need the following things: \nMeasuring tape\nPen and paper\n\n");
			
			printf("Now, just measure the length the wall will be by measuring the permimeter you \nwant it so be on.\n\nNow we need the height that you want it to be, the height must be in a multiple of 75mm to work in accordance with brickwork.\n\n");
			
			printf("Now could you enter the length in metre please :");
			scanf("%i", &len);
			
			printf("\n\nAnd now enter the height also in metres please:");
			scanf("%i", &ht);
			
			printf("\nDo you want the wall built of stone or facing brick?:");
			scanf("%i", &m_chce);
			
			printf("no of brick = %i", &ht);
			
			printf("no of brick = %i", &len);
			
			mtr_sqr = len * ht;
			
			printf("no of brick = %i", &mtr_sqr);
			
			no_brick = mtr_sqr * 59;
			
			printf("no of brick = %i", &no_brick);
			
			break;
			
			
		case 2: 
			printf("Lets price your extension!");
			break;
			
		case 3:
			printf("Lets price your house!");
			break;
			
		case 4:
			printf("Lets try get you a price!");		
			break;
			
		default: 
			printf("Please enter the correct choice, thanks.");
	}
	
	getch();
	return 0;
}

解决方案

I don't think you want the & in

printf("no of brick = %i", <big>&</big>ht);<br />

and the other lines.


这篇关于我刚刚回到编程,请帮助修复此代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆