递归画图
递归把每个位置上的图形赋给map,然后再循环输出。
n=1的时候,规模是1 .直接赋值X。
n问题规模。x,y是开始坐标。
注意,一开始写的pow(3,n-1)报错了,百度了一下…原来是这样的!以后注意!
long double pow(long double,int) float pow(float,int) double pow(double,int) 对于所给的参数int,int,编译器无法判断应该匹配哪个函数,因此报错 可以将代码改为pow(10.0,(int)i)
#include <cstdio>
#include <cmath>
#include <cstring>
#define maxn 730
using namespace std;
char map[maxn][maxn];
void fun(int n,int x,int y){
if(n==1){
map[x][y]='X';
return ;
}
int m= pow(3.0,n-2);//单个的规模
//左上
fun( n-1, x, y);
//右