编辑代码

#include<iostream>
using namespace std;
int aabb(int length,int width)
{
	if(length<width||length<=0||width<=0)
	{
		cout<<"check you input"<<endl;
		return -1;
	}
	if(length%width==0)
	{
		return width;
	}
	int smallwidth=length%width;
	return aabb(width,aabb);
}
int main()
{
	int length;
	int width;
	while(true)
	{
		cout<<"please enter length of rectangle:";
		cin>>length;
		cout<<"please enter width of rectangle:";
		cin>>width;
		if(length<=0||width<=0)
		{
			break;
		}cout<<"the width of square is"<<aabb(length,width)<<endl;
	}
}