pythonExample100/JCP009.py

30 lines
554 B
Python
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

'''
【程序9】
题目:要求输出国际象棋棋盘。
1.程序分析用i控制行j来控制列根据i+j的和的变化来控制输出黑方格还是白方格。
2.程序源代码:
#include "stdio.h"
main()
{
int i,j;
for(i=0;i<8;i++)
 {
  for(j=0;j<8;j++)
   if((i+j)%2==0)
    printf("%c%c",219,219);
   else
    printf(" ");
   printf("\n");
 }
}
'''
import sys
for i in range(8):
for j in range(8):
if(i + j) % 2 == 0:
sys.stdout.write(chr(219))
sys.stdout.write(chr(219))
else:
sys.stdout.write(' ')
print ''