如何将此C ++代码转换为Turbo C? [英] how to convert this C++ code to Turbo C?

查看:93
本文介绍了如何将此C ++代码转换为Turbo C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C ++代码:

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

如何将其转换为printf而不是cout的Turbo C?

How can I convert this to Turbo C like printf instead of 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);

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

.

if realPart and imaginaryPart variables are in data type double.

对于float使用%f,对于int使用%d,对于string使用%s,而不是代码中的%lf.

Use %f for float, %d for int, %s for string instead of %lf in the code otherwise.

这篇关于如何将此C ++代码转换为Turbo C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆