编辑代码

#include <iostream>
using namespace std;
int divideToSquare(int length, int width) {
    if (length < width||length<=0||width<=0)
    {
        cout<<"please check your input"<<endl;
    } 
    if (length % width == 0) {
        return width;
    }
    int smallWidth = length % width;

    return divideToSquare(width, smallWidth);
}

int main() {
    int length = 1680;
    int width = 640;
    cout<<"the width of square is"<<divideToSquare(length,width)<<endl;
	return 0;
}