所以我试着把一个计算三角形高度的程序放在这里:
#include <stdio.h>
void main()
{
float shorty_to_lefty=0.0f , lofty_to_tree=0.0f, lofty=0.0f , shorty=0.0f , arbre=0.0f;
printf("\nRentrer la distance entre le petit et le grand:" );
scanf("%0.2f", &shorty_to_lefty);
printf("\nRentrer la distance entre le grand et l'arbre:" );
scanf("%0.2f", &lofty_to_tree);
printf("\nRentrer la taille du petit" );
scanf("%0.2f", &shorty);
printf("\nRentrer la taille du grand:" );
scanf("%0.2f", &lofty);
arbre= lofty+(shorty_to_lefty/lofty_to_tree)(lofty-shorty)/shorty_to_lefty;
printf("La taille de l'arbre est de %.2f m", arbre);
}但问题是,当我启动它时,scanf只输入1个值,而不是其余的ex: Rentrer la distance entre le petit et le grand:
2
Rentrer la distance entre le grand et l'arbre:
Rentrer la taille du petit
Rentrer la taille du grand:La taille de l'arbre est de -1.#J m在最后一个浮点arbre= lofty+(shorty_to_lefty/lofty_to_tree)(lofty-shorty)/shorty_to_lefty中,当我试图编译时,我得到了这个错误
Arbre.c: In function 'main':
Arbre.c:16:34: error: called object is not a function or function pointer
arbre= lofty+(shorty_to_lefty/lofty_to_tree)(lofty-shorty)/shorty_to_lefty;((shorty_to_lefty/lofty_to_tree)下有一个箭头)
发布于 2021-11-14 15:47:26
问题1:
用%f替换%0.2f。scanf格式说明符与printf的格式说明符相似,但不完全相同。
问题2:
...lofty_to_tree) (lofty - shorty) ...
^
an operator is misssing here, possibly *https://stackoverflow.com/questions/69964479
复制相似问题