#include <math.h>
#include <conio.h>
#include <string.h>
void a()
{
double x,a
printf("Enter the value for x: \n")
scanf("%lf",&x)
a=pow(x,6)-4*pow(x,5)+6*pow(x,4)+1.5*pow(x,3)-8*x+5
printf("The sum of this polynomial is %f\n",a)
}
void b()
{
double x
double sum=0
double a
double b
double c
printf("Please enter the coefficient of ax^2+ bx + c :\n")
printf("a=")scanf("%lf",&a)
printf("b=")scanf("%lf",&b)
printf("c=") scanf("%lf",&c)
printf("x=") scanf("%lf",&x)
sum=a*pow(x,2)+b*pow(x,1)+c
printf("%lf\n",sum)
}
void c()
{
double a,b,c,delt,p,q,x1,x2,t
printf("Please enter the coefficient of ax^2+ bx + c :\n")
printf("a=") scanf("%lf",&a)
printf("b=")scanf("%lf",&b)
printf("c=")scanf("%lf",&c)
delt=b*b-4*a*c
printf("delt=%.3lf\n",delt)
p=-b/(2*a)
printf("p=%.14f\n",p)
if(delt==0)
{ printf("The polynomial ax^2+ bx + c has one double root.\n")
printf("x1=x2=%.3lf\n",p)}
else if(delt>0)
{ q=sqrt(delt)/(2*a)
printf("q=%lf\n",q)
x1=p+qx2=p-q
if(x1<x2)
{ t=x1x1=x2x2=t}
t=a*x1x2=c/t
printf("The polynomial ax^2+ bx + c has two real roots.\n")
printf("x1=%.3lf\n",x1)
printf("x2=%.3lf\n",x2)}
else
{ delt=delt*(-1)
q=sqrt(delt)/(2*a)
printf("The polynomial ax^2+ bx + c has r no real roots.\n") }
}
void main()
{
printf("Please select fuction:")
do
{
char s[32]
scanf("%s", s)
if(_stricmp(s, "a") == 0)
{
a()
}
else if (_stricmp(s, "b") == 0)
{
b()
}
else if (_stricmp(s, "c") == 0)
{
c()
}
else if (_stricmp(s, "q") == 0)
{
break
}
else
{
printf("Input error, please select again:")
continue
}
printf("Please select function:")
} while(1)
}
1)D. 一个非0值2)D. 6 (3/1*2=6)
4)B. 地址
5)D. C语言
6)D. *p与s[0]相等
7)C. 0177666,0101,0133,032
8)B. 1,6
9) C. *** 作数*4
10) D. (1)在对p进行说明的同时进行初始化,使p指向a(2)将变量a的值赋给*p
11) A. read(intfd,char*buf,intcount)
12) B. 联合体变量中成员项所占存储空间量不同,因此,联合体中每一个成员项的地址不是同一地址
13) D. 'A'
14) B. a=1,b=111
15) C. 成员中占内存量最大者所需的容量
A
A
A
B
B
B
A
A
B
A
===
刚才楼主怎么删了。。花了老半天才做完,楼主给分吧。。。
1 编写一程序,设置一个排序函数将数组按照从小到大的顺序进行排序,其中有两个形式参数,一个为指向数组的指针P,另一个参数为数组的元素个数N.在主函数main()中要求输入10个书存入数组data[10]中,同时要求调用函数sort对data进行排序,并在main()中输出最终的排序结果:#include<stdio.h>
void sort(int *p,int n) /*从大到小排列*/
{ int max, i,j
for(i=0i<9i++)
{ max=p[i]
for(j=i+1j<10j++)
if(max<p[j])
max=p[j]
}
}
main()
{int date[10],*p,n
for(n=o,n<10,n++)
scanf("%4d",&date[n]) /*为数组赋初值*/
for(n=o,n<10,n++)
printf("%4d",&date[n]) /*输出数阻值*/
p=date
sort(p,n)/*调用函数*/
for(n=o,n<10,n++) /*输出调用后的数阻值*/
printf("%4d",&date[n])
printf("\n")
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)