简体   繁体   English

如何将此 C++ 代码转换为 Turbo C?

[英]how to convert this C++ code to Turbo C?

C++ code: C++代码:

cout << "Roots are complex and different."  << endl;
cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl;
cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl;

How can I convert this to Turbo C like printf instead of cout ?如何将其转换为 Turbo C 之类的printf而不是cout

May be you are seeking for this:可能你正在寻找这个:

printf("Roots are complex and different.\n");
printf("x1 = %lf+%lfi\n",realPart,imaginaryPart);
printf("x2 = %lf-%lfi\n",realPart,imaginaryPart);

if realPart and imaginaryPart variables are in data type double .如果realPartimaginaryPart变量的数据类型为double

Use %f for float , %d for int , %s for string instead of %lf in the code otherwise.否则在代码中使用%f表示float%d表示int%s表示string而不是%lf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM