我不能使用C ++函数sin(),并cos()因引起的PS3 3.40 SDK编译器的某些问题。sin()&的计算是什么,cos()所以我可以在不需要的情况下使用函数math.h?
到目前为止,我已经想出了这些,但它们似乎无法正常运行?
float sin(float deg) {
bool neg = false;
while (deg >= 360) deg = deg - 360;
while (deg < 0) deg = deg + 360;
if (deg > 180) {
deg = deg - 180;
neg = true;
}
float ret = (float)(4*deg*(180-deg))/(40500-(deg*(180-deg)));
if (neg)return ret*-1;
return ret;
}
float cos(float AnglesDeg)
{
float AnglesRad = DegreesToRadians(AnglesDeg);
float Rad = (float)(PI/2.0f)-AnglesRad;
float ang = …Run Code Online (Sandbox Code Playgroud) 所以在我的C++程序中,我试图复制C#BitConverter.GetBytes()函数,或者至少找到一些方法,它会返回相同的结果,(顺便说一下,我不能使用std::vector<unsigned char>我见过的人在其他论坛上推荐的).
我正在使用它,所以我可以拿一个int然后得到byte[]它然后接受byte[]并使用它来设置特定内存地址的内存.我也试过了
int x;
static_cast<char*>(static_cast<void*>(&x));
Run Code Online (Sandbox Code Playgroud)
没有运气.任何建议表示赞赏!
所以我想尝试使用Ceasar Cipher char *,我写了一个简单的函数:
char * Encrypt(char * s, int k)
{
char * c = s;
for(int i = 0; i < strlen(s); i++)
c[i] += k;
return c;
}
Run Code Online (Sandbox Code Playgroud)
这似乎看起来应该有效,但事实并非如此.它在运行程序时抛出错误.
以下是我如何调用此函数的示例:
int main()
{
cout << Encrypt("hello", 2) << endl;
system("pause");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在你说"为什么不只是使用string?"之前,答案是我在某个SDK上编写C++,在使用时会导致编译器错误string.好的但是,任何形式的帮助都将非常感谢,谢谢!