程序执行后的输出结果是__x-y=5________。(5分)
2.求一元二次方程ax2+bx+c=0的解。
#include <stdio.h>
(1分)
int main()
{
double a,b,c,disc,x1,x2,realpart,imagpart;
scanf("%lf,%lf,%lf", &a,&b,&c);
disc=b*b-4*a*c;
if( ) (2分)
printf("has two equal roots:%8.4f\n",-b/(2*a));
else
if( ) (2分)
{
x1=(-b+sqrt(disc))/(2*a);
x2=(-b-sqrt(disc))/(2*a);
printf("has distinct real roots:%8.4f and %8.4f\n",x1,x2);
}
else
{
realpart=-b/(2*a);
imagpart= sqrt(-disc)/(2*a) ;
printf(" has complex roots:\n");
printf("%8.4f+%8.4fi\n",realpart,imagpart);
printf("%8.4f-%8.4fi\n",realpart,imagpart);
}
return 0;
}
3.下面是求一个3*3矩阵对角线元素的和,请在空白处填上适当的内容.
void main()
{
int a[3][3]={{1,2,3},{4,5,6},{6,7,8}}, sum=0;
int i,j;
for(i=0;;i++) (1分)
for(j=0;j<3;j++)
(2分)
; (2分)