编程语言打出一个数学公式

用C++语言打出下面的一个数学式子,谢谢
025(cos(10π(x-1.5))+1)

第1个回答  2014-05-15
#include<iostream>
using namespace std;
int main()
{
cout<<"025(cos(10π(x-1.5))+1)"<<endl;
cout<<endl;
return 0;
}
//不知道你要使用这个式子还是要利用这个式子计算,我这个是只打印式子,你要是想利用式子
//进行计算再提问就行了。
第2个回答  2014-05-15
#include<stdio.h>
#include<math.h>
int main()
{
float a;
float pi=3.1415926;
float x;
scanf("%f",&x);
a=25*(cos(10*pi*(x-1.5))+1);
printf("%.4f",a);

}

追问

  你好,我的程序为
  bo(i,0) = 0.25*(cos(10*PI*(x-1.5))+1)
  bo(i,1) = 0.0
  bo(i,2) = 0.0
  总是有错误
  Error: The shapes of the array expressions do not conform.
  bo(i,0) = 0.25*(cos(10*PI*(x-1.5))+1)

追答

bo(i,0) 没有这个变量的定义法则。。

你可以改为 bo_i_1 这样可以 ,只能是数字,—— 和 字母

本回答被提问者采纳
第3个回答  2014-05-15
#define pi 3.1415926

0.25*(cos(10*pi*(x-1.5))+1)
第4个回答  2014-05-15
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "0.25(cos(10π(x-1.5))+1)" << endl;
}
相似回答