C 计算右梯形的周长
我不确定这段代码中缺少了什么 我正在创建一个工具,您可以在C编程中计算右梯形的周长,周长线不断显示错误C 计算右梯形的周长,c,C,我不确定这段代码中缺少了什么 我正在创建一个工具,您可以在C编程中计算右梯形的周长,周长线不断显示错误 #include<stdio.h> #include<math.h> int main () { /* variable definition: */ float baseA, baseB, height, perimeter; /* Prompt user for baseA */ printf("Enter the first base of
#include<stdio.h>
#include<math.h>
int main () {
/* variable definition: */
float baseA, baseB, height, perimeter;
/* Prompt user for baseA */
printf("Enter the first base of the trapezoid: \n");
// Input the base
scanf("%f", &baseA);
/* Prompt user for baseB */
printf("Enter the second base of the trapezoid: \n");
// Input the baseB
scanf("%f", &baseB);
/* Prompt user for height */
printf("Enter the height of the trapezoid: \n");
// Input the height
scanf("%f", &height);
// Calculate the Perimeter
perimeter = baseA + baseB + height + sqrt(height*height + (baseB –
baseA)*(baseB – baseA) );
// Print the result
printf("Perimeter is: %f\n", perimeter);
return 0;}`
#包括
#包括
int main(){
/*变量定义:*/
浮式底座A、底座B、高度、周长;
/*提示用户输入baseA*/
printf(“输入梯形的第一个底面:\n”);
//输入基数
scanf(“%f”、&baseA);
/*提示用户输入baseB*/
printf(“输入梯形的第二个底面:\n”);
//输入baseB
scanf(“%f”、&baseB);
/*提示用户输入高度*/
printf(“输入梯形的高度:\n”);
//输入高度
扫描频率(“%f”和高度);
//计算周长
周长=baseA+baseB+高度+sqrt(高度*高度+(baseB-
baseA)*(baseB–baseA));
//打印结果
printf(“周长为:%f\n”,周长);
返回0;}`
用户应该能够输入任意数字,并使用C代码格式的毕达哥拉斯定理计算右梯形的结果。似乎您没有使用
-
字符进行除法。我复制了您的代码并得到了错误:
error: non-ASCII characters are not allowed outside of literals and identifiers
perimeter = baseA + baseB + height + sqrt(height*height + (baseB – baseA)*(baseB - baseA) );
我刚刚把你的
-
换成了-
,它成功了。出现了什么错误?你能说得更清楚一点吗?我不敢相信事情会这么简单。smh。现在我觉得自己像个白痴。谢谢瑞兰。我还没有弄清楚如何阅读错误页面。很高兴我能帮上忙。顺便说一句,如果你点击我答案旁边的复选框就好了:)哦,对不起。我也是新的这个网站也。