Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
173621 A班--林奕朗 分形图1 C++ 无测评数据 0 0 MS 0 KB 515 2024-08-20 22:14:25

Tests(0/0):


#include<iostream> #include<math.h> using namespace std; const int N=2187; bool a[N+5][N+5]; void op(int n,int x,int y){ int d=n/3; if(n==1){ a[x][y]=1; return ; } op(d,x,y); op(d,x,y+d*2); op(d,x+d,y+d); op(d,x+d*2,y); op(d,x+d*2,y+d*2); } int main(){ int n; while(n!=-1){ cin>>n; op(pow(3,n),0,0); for(int i=0;i<pow(3,n);i++){ for(int j=0;j<pow(3,n);j++){ if(a[i][j])cout<<"*"; if(a[i][j]==0) cout<<" "; } cout<<"\n"; } } return 0; }