该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
首先,你的原来的程序是没什么问题的,问题就在于那个定义,很奇怪,似乎现在的vc的头文件里面不再有那种定义方式,具体原因我也不清楚。所以我这里按照c++的方式重新写了一个。
/* Program 2.17 Working with complex numbers */
#include
#include
#include
using namespace std;
int main(void)
{
complex cx = { 1.0, 3.0 };
complex cy = { 1.0, 4.0 };
//double complex cx = 1.0 + 3.0 * I;
//double complex cy = 1.0 – 4.0 * I;
printf(“Working with complex numbers:”);
printf(“\nStarting values: cx = %.2f%+.2fi cy = %.2f%+.2fi”,real(cx), imag(cx), real(cy), imag(cy));
//double complex sum = cx + cy;
complex sum = cx + cy;
printf(“\n\nThe sum cx + cy = %.2f%+.2fi”,
real(sum), imag(sum));
//double complex difference = cx – cy;
complex difference = cx – cy;
printf(“\n\nThe difference cx – cy = %.2f%+.2fi”, real(difference), imag(difference));
//double complex product = cx*cy;
complex product = cx*cy;
printf(“\n\nThe product cx * cy = %.2f%+.2fi”,
real(product), imag(product));
//double complex quotient = cx / cy;
complex quotient = cx / cy;
printf(“\n\nThe quotient cx / cy = %.2f%+.2fi”,
real(quotient), imag(quotient));
//double complex conjugate = conj(cx);
complex conjugate = conj(cx);
printf(“\n\nThe conjugate of cx = %.2f%+.2fi”,
real(conjugate), imag(conjugate));
return 0;
}
今天的文章c语言 complex.h,vs2015编译出错<complex.h>,小白求解。分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/26477.html