知识库

C++语言开发示例:19. 数学运算

2025-02-01 20:22:56 李腾 1 次阅读

arith.cpp

#include <iostream>

int main()
{
    using namespace std;
    float hats, heads;

    cout.setf(ios_base::fixed, ios_base::floatfield);
    cout << "Enter a number: ";
    cin >> hats;
    cout << "Enter another number: ";
    cin >> heads;

    cout << "hats = " << hats << "; heads = " << heads << endl;
    cout << "hats + heads = " << hats + heads << endl;
    cout << "hats - heads = " << hats - heads << endl;
    cout << "hats * heads = " << hats * heads << endl;
    cout << "hats / heads = " << hats / heads << endl;
}
转载请注明转自www.hylab.cn,原文地址:C++语言开发示例:19. 数学运算

评论 (0)

登录后发表评论

暂无评论,快来发表第一条评论吧!