C语言实现
#include<stdio.h>void oddRow1();
void evenRow1();void main()
{for (int i = 1; i <= 8; i++){if(i % 2 == 1)oddRow1();elseevenRow1();}
}void oddRow1()
{for (int i = 1; i <= 4; i++)printf("■□"); printf("\n");
}void evenRow1()
{for (int i = 1; i <= 4; i++)printf("□■"); printf("\n");
}
运行结果:
python语言实现
def oddRow():for i in range(1,5):print("□■",end = "")print("")def evenRow():for i in range(1,5):print("■□",end = "")print("")#主程序
for i in range(1,9):if i % 2 == 1:oddRow()else:evenRow()
运行结果:
★finished by songpl, 2018.12.6