编辑代码

#include<iostream>
using namespace std;
int divideSquare(int length,int width)
{
	int smallwidth;
	if(length<width||length<=0||width<=0)
	cout<<"error";
	if(length%width==0)
	return width;
	for(;width==length;)
	smallwidth=length%width;
	length=width;
	width=smallwidth;
	return smallwidth;

 } 
 int main(){
   int length =9,width=3;
   cout<<"农民分得正方形土地宽为"<<divideSquare(length,width);
 }