一个求差商的C语言程序,我检查了很久都没找到问题出在哪里.希望能得到高手的帮助。

一个求差商的C语言程序,我检查了很久都没找到问题出在哪里.希望能得到高手的帮助。,第1张

老大你的for循环后边全都有分号,那个就更本部循环好吧!!!!

修改以后的代码:

int main()

{int i

float A[4],B[3],C[2],D,

x[5]={0.4,0.55,0.65,0.8,0.9},y[5]={0.41075,0.57815,0.69675,0.88811,1.02652}

for(i=0i<5i++)

A[i]=(y[i+1]-y[i])/(x[i+1]-x[i])

for(i=0i<4i++)

printf("A[%d]=%f\t",i,A[i])

for(i=0i<4i++)

B[i]=(A[i+1]-A[i])/(x[i+2]-x[i])

for(i=0i<3i++)

printf("B[%d]=%f\t",i,B[i])

for(i=0i<3i++)

C[i]=(B[i+1]-B[i])/(x[i+3]-x[i])

for(i=0i<2i++)

printf("C[%d]=%f\t",i,C[i])

D=(C[i+1]-C[i])/(x[4]-x[0])

printf("D=%f\t",D)

return 0

}

修改以后的结论:

A[0]=1.116000 A[1]=1.186001 A[2]=1.275733 A[3]=1.384101 B[0]=0.280003 B[1]=0.358930 B[2]=0.433471 C[0]=0.197316 C[1]=0.212976 D=-0.397131

#include "stdio.h"

main()

{  int a,b

printf("请输入两个整数(a,b):")

scanf("%d,%d"改困,&a,&b) 塌携    团歼伏                  

printf("和:%d\n",a+b)         

printf("差:%d\n",a-b)

printf("积:%d\n",a*b)

printf("商:%f\n",(float)a/b)}

代棚激码一:

#include <stdio.h>

int main(void)

{

int num1, num2

scanf("%d%d",&num1,&num2)

printf("%d + %d = %d\n"链顷袜,num1,num2,num1+num2)

printf("%d - %d = %d\n", num1, num2, num1-num2)

printf("%d * %d = %d\n", num1, num2, num1*num2)

if (num2) printf("%d / %d = %g\n", num1, num2, (double)num1/num2)

else printf("ERROR ,DIV BY ZERO\n")

printf("%d %% %d = %d\n", num1, num2, num1%num2)

return 0

}

代码二:

#include <stdio.h>

void main()

{

int x, y

printf("please enter a,b,c:")

scanf("%d,%d",&x,&y)

printf("\nx+y=%d\n",x+y)

printf("x-y=%d\n",x-y)

printf("x*y=%d\n",x*y)

printf("x/y=%d\n",x/y)

printf("x%%y=%d\n",x%y)

}

下图为C语言算术运算符

扩展资料:

算术运算符实例:

#include <stdio.h>

main()

{

int a = 21

int b = 10

int c

c = a + b

printf("Line 1 - c 的值是 %d\n", c )

c = a - b

printf("Line 2 - c 的值是 %d\n", c )

c = a * b

printf("Line 3 - c 的值是 %d\n", c )

c = a / b

printf("Line 4 - c 的值是 %d\n", c )

c = a % b

printf("乎蠢Line 5 - c 的值是 %d\n", c )

c = a++

printf("Line 6 - c 的值是 %d\n", c )

c = a--

printf("Line 7 - c 的值是 %d\n", c )

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12564828.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存