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

how to convert this C++ code to Turbo C?

C++代码:

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

如何将其转换为 Turbo C,例如 printf 而不是 cout

可能你正在寻找这个:

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

如果 realPartimaginaryPart 变量的数据类型为 double

float 使用 %f,对 int 使用 %d,对 string 使用 %s 而不是 %lf否则代码。