注意:部分函数名我运用的是名字缩写(zxr),请自行更改。
1. 编写一个函数,由实参传来一个整数n,将它各个位上的数字逆序输出,例如输入
123,输出为321。
#include <stdio.h>
int main()
{
int shunxu(int x);
int n;
printf("please input a number:");
scanf("%d",&n);
shunxu(n);
return 0;
}
int shunxu(int x)
{
int i=0;
while(x != 0)
{
i = i*10 + x%10;
x = x/10;
}
printf("%d",i);
return 0;
}
2. 求方程ax 2 +bx+c=O的根,用3个函数分别求当:b2-4ac大于0、等于0和小于0时的根并输出结果。从主函数输入a、b、c 的值。
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
float math1(float x,float y,float z);
float math2(float x,float y,float z);
void math3();
float math4(float x,float y,float z);
float d;
int main()
{
float a,b,c,x1,x2;
printf("please input three number a b c:");
scanf("%f %f %f",&a,&b,&c);
d=b*b-4*a*c;
if(d>0)
{