1、有一分段函数如下,请编写程序,输入x值,输出y值。当x<=-1 y=sinx+2cosx当-1<x<=1 y=1/(x2-1)当x>1 y=sqrt(x3-1)
2、输入一批正整数(输入0或负数时结束输入),找出这批数中能被2或3整除、但不能同时被2和3整除的的数,并将这些数按从大到小的顺序排序后输出。
第一题。。。
我写了个这样的程序求改错!!!
#include<stdio.h>
#include<math.h>
void main()
{
int x;
scanf("%d",&x);
if(x<=-1)printf("%d",sinx+2*cosx);
else if(x<=1)printf("%d",1/(x^2-1));
else printf("%d",sqrt(x^3-1));
}
大概是软件不认识sin和cos 所以很纠结= =
这是我们考前练习题哦哦哦各位大大求帮助!!
#include<stdio.h>
#include<cmath>
int main()
{
float x,y;
scanf("%f",&x);
if (x<=-1){
y=3*sqrt(-x+2)+1;
printf("%.5f",y);}
else if (x>=10){
y=sqrt((x+1)/(2*x*x));
printf("%f",y);}
else{
y=pow(x,5)+1;
printf("%.0f",y);}
}
扩展资料
using namespace std;
class CStudent
{
public:
char szName[20];
int age;
};
int main()
{
CStudent s;
fstream ioFile("students.dat", ios::in|ios::out);//
if(!ioFile) {
cout << "error" ;
return 0;
}