简体   繁体   English

我应该怎么做才能扩展C ++中的输出值

[英]What should I do to extend output values in c++

This program converts Celsius degrees to Fahrenheit degrees and Kelvin. 该程序将摄氏度转换为华氏度和开尔文度。 When I run this code in Dev C++ I get Celsius values going from 2 to 300. How do I get the code to output Celsius values starting from -300 and ending at 300? 当我在Dev C ++中运行此代码时,我得到的Celsius值从2到300。如何获取代码以输出从-300到300的Celsius值?
I clearly set cels = -300 in the for loop. 我明确地在for循环中设置了cels = -300 So why does the output start from 2? 那么为什么输出从2开始呢?

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double cels, fah, kel, cels2fah, cels2kel, fah2cels, fah2kel;
cout<<"My Name \n";
cout<<"Program 8.0 "<<endl;
cout<<"\n\n";
cout<<"Celsius     Fahrenheit        Kelvin \n"
   <<"Degrees      Degrees         --------\n"
   <<"--------    -----------      --------\n";


for(cels = -300; cels<= 300; cels++)
{
 cels2fah = (cels*9.0/5)+32.0;
 cels2kel = cels+273.15;
 setprecision(4.0);
 cout<<setw(3)<< cels <<"    "
    <<setw(12)<< cels2fah <<"   "
    <<setw(14)<< cels2kel <<"   \n";
}
system("PAUSE");
return 0;
}

I think the output is scrolling as has too many lines to hold in the buffer on the screen (tried on VS 2010/XP). 我认为输出正在滚动,因为有太多行无法容纳在屏幕的缓冲区中(在VS 2010 / XP上尝试过)。 The final output has lines only from 2 onwards to 300. 最终输出的行数仅从2开到300。

Don't worry, the output is printing but unforunately not seen in the final window on Windows at least. 不要担心,输出是打印但不幸的是至少在Windows的最终窗口中看不到。

Try logging the output to an output file instead. 尝试将输出记录到输出文件中。

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

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