寻找更好的方法来编写这个程序 C++

looking for better ways to write this program c++

本文关键字:程序 C++ 更好 方法 寻找      更新时间:2023-10-16

有没有更好的方法来使用这个程序。 用于加法 程序正在添加 a 和 b 以获得总和。 我正在寻找变得更好的方法。

#include <iostream>
using namespace std;
int a = 0;
int b = 0;
int s = 0;
int main()
{
cout << "Type a Number: ";
cin >> a ;
cout << "Type another Number:"; 
cin >> b;
cout << "you sum is... ";
cout << int (s = (b + a)) << endl ;
system ("pause"); 
}
#include<iostream>
using namespace std;
int main()
{
int a=0,b=0,sum=0;
cout<<"Type a and b"<<endl;
cin>>a>>b;
sum=a+b;
cout<<sum<<endl;
return 0;
}