c语言改错题,急!!!!
#include<stdio.h>#include<math.h>main(){doublea,b,c,s,ss;printf("Pleaseinputtheedgeso...
#include <stdio.h>
#include <math.h>
main ()
{
double a, b, c, s, ss;
printf("Please input the edges of the triangle:');
scanf("%f,%f,%f", a, b, c);
if (a + b < c && a + c > b && b + c > a)
s = (a + b + c)%2;
ss = sqrt(s*(s-a)*(s-b)*(s-c);
printf("The area of this triangle is %.2lf", ss);
else
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
}
3-6个错 展开
#include <math.h>
main ()
{
double a, b, c, s, ss;
printf("Please input the edges of the triangle:');
scanf("%f,%f,%f", a, b, c);
if (a + b < c && a + c > b && b + c > a)
s = (a + b + c)%2;
ss = sqrt(s*(s-a)*(s-b)*(s-c);
printf("The area of this triangle is %.2lf", ss);
else
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
}
3-6个错 展开
5个回答
展开全部
#include <stdio.h>
#include <math.h>
int main ()
{
double a, b, c, s, ss;
printf("Please input the edges of the triangle:");
//printf("Please input the edges of the triangle:");
scanf("%f,%f,%f", &a, &b, &c);
//scanf("%f,%f,%f", &a, &b, &c);
if (a + b < c && a + c > b && b + c > a)
s = (a + b + c)%2;
//double双精度不可以使用取余的操作
ss = sqrt(s*(s-a)*(s-b)*(s-c));
//ss = sqrt(s*(s-a)*(s-b)*(s-c));
printf("The area of this triangle is %.2lf", ss);
else
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
//else和if无法匹配了!这个要根据你的语义修改
}
#include <math.h>
int main ()
{
double a, b, c, s, ss;
printf("Please input the edges of the triangle:");
//printf("Please input the edges of the triangle:");
scanf("%f,%f,%f", &a, &b, &c);
//scanf("%f,%f,%f", &a, &b, &c);
if (a + b < c && a + c > b && b + c > a)
s = (a + b + c)%2;
//double双精度不可以使用取余的操作
ss = sqrt(s*(s-a)*(s-b)*(s-c));
//ss = sqrt(s*(s-a)*(s-b)*(s-c));
printf("The area of this triangle is %.2lf", ss);
else
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
//else和if无法匹配了!这个要根据你的语义修改
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
#include <math.h>
main ()
{
double a, b, c, s, ss;
printf("Please input the edges of the triangle:"); 注意双引号" "
scanf("%lf,%lf,%lf", &a,& b,& c); 因为是double,所以输入应改为%lf,虽然语法没错,但结果有误。还有别忘了地址运算符&
if (a + b > c && a + c > b && b + c > a) 三角形里面应该是任何两边大于第三边
s = (a + b + c)/2; %这是求余运算符,此时应该用整除运算符/
ss = sqrt(s*(s-a)*(s-b)*(s-c)); 少了)
printf("The area of this triangle is %10.2lf", ss); 10.2代表是输出的数据共占10列,小数点有2位,不能直接写.2,这是语法错误
else
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
}
C语言在于多多上机练习!加油了!
#include <math.h>
main ()
{
double a, b, c, s, ss;
printf("Please input the edges of the triangle:"); 注意双引号" "
scanf("%lf,%lf,%lf", &a,& b,& c); 因为是double,所以输入应改为%lf,虽然语法没错,但结果有误。还有别忘了地址运算符&
if (a + b > c && a + c > b && b + c > a) 三角形里面应该是任何两边大于第三边
s = (a + b + c)/2; %这是求余运算符,此时应该用整除运算符/
ss = sqrt(s*(s-a)*(s-b)*(s-c)); 少了)
printf("The area of this triangle is %10.2lf", ss); 10.2代表是输出的数据共占10列,小数点有2位,不能直接写.2,这是语法错误
else
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
}
C语言在于多多上机练习!加油了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
printf("Please input the edges of the triangle:');
改成;printf("Please input the edges of the triangle:");
scanf("%f,%f,%f", a, b, c);
改成;scanf("%f,%f,%f",&a,&b,&c);
if (a + b < c && a + c > b && b + c > a)
s = (a + b + c)%2;
ss = sqrt(s*(s-a)*(s-b)*(s-c);
printf("The area of this triangle is %.2lf", ss);
改成:if (a + b < c && a + c > b && b + c > a)
{
s = (a + b + c)%2;
ss = sqrt(s*(s-a)*(s-b)*(s-c));
printf("The area of this triangle is %.2lf", ss);
}
这句理解不了 s = (a + b + c)%2;
改成;printf("Please input the edges of the triangle:");
scanf("%f,%f,%f", a, b, c);
改成;scanf("%f,%f,%f",&a,&b,&c);
if (a + b < c && a + c > b && b + c > a)
s = (a + b + c)%2;
ss = sqrt(s*(s-a)*(s-b)*(s-c);
printf("The area of this triangle is %.2lf", ss);
改成:if (a + b < c && a + c > b && b + c > a)
{
s = (a + b + c)%2;
ss = sqrt(s*(s-a)*(s-b)*(s-c));
printf("The area of this triangle is %.2lf", ss);
}
这句理解不了 s = (a + b + c)%2;
追问
第1题:编程题1(30分)
题目描述:输入任意一个字符串,编程求出该字符串中字母l出现的总次数。
例如,输入:hello world
输出:3
第2题:编程题2
题目描述:编写程序,从键盘上输入10个整数,然后删除其中的最小值和最大值,最后输出删除前后的数组。
追答
1、
#include
#define MAX 40
void main()
{
char a[MAX];
int count=0,i;
char l='l';
printf("输入字符串:");
gets(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]=='l')
{
count++;
}
}
printf("字符串中字母l出现的总次数:%d\n",count);
}
2、要用指针,不太会啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-05-27
展开全部
1、输入没有地址符&,对应的格式符有些编译系统也不能这样写
2、 ss = sqrt(s*(s-a)*(s-b)*(s-c);少一边括号;
3、if (a + b < c && a + c > b && b + c > a)中a+b<c应该是a+b>c
4、if语句下面的两条语句应该合成复合语句
2、 ss = sqrt(s*(s-a)*(s-b)*(s-c);少一边括号;
3、if (a + b < c && a + c > b && b + c > a)中a+b<c应该是a+b>c
4、if语句下面的两条语句应该合成复合语句
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include "stdafx.h"
#include<string.h>
#include <math.h>
int _tmain(int argc, _TCHAR* argv[])
{
double a, b, c, s, ss;
printf("Please input the edges of the triangle:");
scanf("%f,%f,%f", &a, &b, &c);
if (a + b < c && a + c > b && b + c > a)
{
s = (int)(a + b + c) % 2;
ss = sqrt(s*(s-a)*(s-b)*(s-c));
printf("The area of this triangle is %.2lf", ss);
}
else
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
getchar();
return 0;
}
你自己对照一下
#include<string.h>
#include <math.h>
int _tmain(int argc, _TCHAR* argv[])
{
double a, b, c, s, ss;
printf("Please input the edges of the triangle:");
scanf("%f,%f,%f", &a, &b, &c);
if (a + b < c && a + c > b && b + c > a)
{
s = (int)(a + b + c) % 2;
ss = sqrt(s*(s-a)*(s-b)*(s-c));
printf("The area of this triangle is %.2lf", ss);
}
else
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
getchar();
return 0;
}
你自己对照一下
追问
不得增加删除行,不得更改结构
追答
double a, b, c, s, ss;
printf("Please input the edges of the triangle:");//后面是引号,不是单引号
scanf("%f,%f,%f", &a, &b, &c);//这里要取地址符scanf("%f,%f,%f", &a, &b, &c);
if (a + b b && b + c > a)
{
s = (int)(a + b + c)%2; //类型转化问题,double类型与整型要转化
ss = sqrt(s*(s-a)*(s-b)*(s-c));//少括号
printf("The area of this triangle is %.2lf", ss);
}
else //对于else而言if是不可见的,所以要加上括号
{
printf("%lf, %lf, %lf can not form a triangle!!", a, b, c);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询