// test13.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
using namespace std;

class Solution {
public:
	int Add(int num1, int num2)
	{
		while (num2--)
		{
			num1++;
		}
		return num1;
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	Solution so;
	int num1,num2;
	while (true)
	{
		cin >> num1 >> num2;
		cout << num1 << "和" << num2 << "的值是:" << so.Add(num1, num2) << endl;
	}

}

注:这是利用了++ -- 运算,另外还有一个常用的方法就是使用 与 或 异或 运算

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
相关资源
相似解决方案