编辑代码

#include<iostream>
using namespace std;
int a(int length, int width)
{
	if(length<width || length<=0 || width<=0)
	{
		cout<<"please check your input!"<<endl;
		return -1;
	}
	if(length % width ==0)
	{
		return width;
	}
	int smallwidth=length%width;
	return a(width, smallwidth);
}
int main()
{
	int length;
	int width;
	cout<<"please enter length"<<endl;
	cin>>length;
	cout<<"please enter width"<<endl;
	cin>>width;
	cout<<"the width of square is "<<a(length, width)<<endl;
	return 0;
}