初学者求助大佬们 c语言函数题 c语言函数编程题
- c语言程序设计自定义函数最少50行,刚刚入门简单点啊,老大们
- 一道用C语言补充函数,要求求出正弦函数和平方根函数。里面有详细的要求。求助C语言的大佬们,急!
- 初学者,一道C语言函数题
- c语言程序题求大佬帮忙
c语言程序设计自定义函数最少50行,刚刚入门简单点啊,老大们
#include <iostream>
using namespace std;
const size=3;
template<class T>
class vector
{
T* v;
public:
vector()
{
v=new T[size];
for(int i=0;i<size;i++)
v[i]=0;
}
vector(T* a)
{
for(int i=0;i<size;i++)
v[i]=a[i];
}
};
int main()
{
int x[3]={1,2,3};
int y[3]={4,5,6};
vector<int>v1;
vector<int>v2;
v1=x;
v2=y;
return 0;
}
一道用C语言补充函数,要求求出正弦函数和平方根函数。里面有详细的要求。求助C语言的大佬们,急!
#include <stdio.h>
#include <math.h>
int main () {
double SIN (double x, double eps);
double SQRT (double x, double eps);
double x, eps1=1.0e-3, eps2=1.0e-3;
printf ("input x \n");
scanf ("%lf", &x);
printf ("SIN(%g)=%f \n", x, SIN(x,eps1));
printf ("sin(%g)=%f \n", x, sin(x));
printf ("SQRT(%g)=%f \n", x, SQRT(x,eps2));
printf ("sqrt(%g)=%f \n", x, sqrt(x));
return 0;
}
double SIN (double x, double eps) {
double sum = 0;
int sign = 1; /* 控制正负符号,初值为正 */
double f = 1; /* f = (2n+1)!,初值为1 */
double t = x; /* t = sign * x^(2n+1) / f,初值为x */
int i;
for (i=1; fabs (t)>=eps; i+=2) {
if (i>1) /* 第1项之后,f累乘i*(i-1) = i! = (2n+1)! */
f *= i*(i-1);
t = sign * pow (x, i) / f;
sum += t;
sign *= -1;
}
return sum;
}
double SQRT(double x, double eps) {
double x0, x1;
x0 = x / 2.0; /* x0取S/2 */
x1 = (x0 + x/x0) / 2.0;
do {
x0 = x1;
x1 = (x0 + x/x0) / 2.0;
}
while (fabs (x1-x0) >= eps);
return x1;
}
如有疑问,可点击头像联系我~~
初学者,一道C语言函数题
#include<stdio.h>
void invert(int n)
{
if(n/10==0)
{
printf("%d\n",n);
return;
}
else
{
printf("%d",n%10);
invert(n/10);
}
}
main()
{
int n;
scanf("%d",&n);
invert(n);
}
c语言程序题求大佬帮忙
#include
int main()
{int n,i,j,s=0;
struct stud{
char id[10];
char name[10];
int score;
}stu[10];
scanf("%d",&n);
for(i=j=0;i {scanf("%s %s %d",stu[i].id,stu[i].name,&stu[i].score); s+=stu[i].score; if(stu[i].score>stu[j].score)j=i; } printf("The average score=%.2f\n",(float)s/n); printf("The student who has the highest score is:%s %s %d",stu[j].id,stu[j].name,stu[j].score); return 0; }