给出一个矩形的长宽,求出可以折多少个正方形。输入两个正整数,分别是长和宽。
【输入样例】
3 4
【输出样例】
4
说明:
递归,简单题。
代码:
#include<iostream>
using namespace std;
int run(int lenth,int width)
{
if(lenth%width==0)
return lenth/width;
else
{
return run(width,lenth%width)+lenth/width;
}
}
int main(void)
{
int lenth,width;
cin>>lenth>>width;
cout<<run(lenth,width);
return 0;
}
运行图