我从“使用 C++ 编程和原理”编写这个程序,我需要编写一个程序,它需要太多的整数并找到和、差、大于和小于值以及比率。
出于某种原因,我不能得到大于和小于工作。它实际上并不执行该功能。它只是简单地打印数字,即:4 将小于 2。
我的第二个问题是我如何编写一个可以为我计算比率的方程?
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
inline void keep_window_open() {char ch;cin>>ch;}
int main()
{
int a;
int b;
cout<<"Enter two values.\n";
cin>>a; cin>>b;
if (a > b);cout<< a << " Is greater than " << b << "\n";
if(a < b);cout<< a << " Is less than " << b << "\n";
cout<<a << " plus " << b << " is " << a+b << "\n";
cout<<a << " minus " << b << " is " << a-b << "\n";
keep_window_open();
return 0;
}