c++ - 我在 visual studio 中的程序没有显示任何内容,我的代码有什么问题?

标签 c++ visual-studio

我正试图为我妹妹找出一道数学题。因此,作为我自己的一个小项目,我正在尝试编写一个程序来解决这个问题。目标是找出您成为百万富翁时的年龄。它看起来不错,但它没有产生任何东西。我什至无法将任何内容打印到屏幕上。它出什么问题了?我正在使用 C++。

int _tmain()
{
    int age = 21, year = 1;
    double salary, salaryIncrease, amountSaved, interestEarned, 
        total, totalMed;
    salary = 38500, salaryIncrease = .10, 
        interestEarned = .045, amountSaved = .25, total = 0;    
    while (total < 1000000){
        if (year % 3 == 0){
            salary = salary * salaryIncrease + salary;
        }
        if (year = 10) interestEarned = .0525;
        totalMed = salary * amountSaved;
        total = (total + totalMed)*interestEarned;
        age++;
        year++;
    }
    cout << "Age = " << age << endl;
    cout << "Total = " << total << endl;
    cout << "hello?" << endl;
    return 0;
}

最佳答案

if ( year = 10 )

需要

if( year == 10 )

关于c++ - 我在 visual studio 中的程序没有显示任何内容,我的代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34805050/

相关文章:

visual-studio - 如何请求对 TFS 中的单个文件进行代码审查?

visual-studio - 无法安装 Qt 5 Visual Studio 插件

c++ - OpenMP 的缩放问题

sql-server - 使用 Visual Studio 创建 SQL 数据库并添加到项目

visual-studio - 包管理初始化失败 : Access Denied Error when opening Visual Studio 2017

c++ - 将视频流式传输到多个源或从多个源流式传输视频

C++ 控制台应用程序立即退出?

c++ - 创建 unordered_set 的 unordered_set

c++ - "warning C4800: ' int' : forcing value to bool 'true' or 'false' "不同场景下的不同行为

c++ - 在 C++ 资源中没有更频繁地提及堆栈和堆是否有特殊原因?