pythonExample100/JCP008.py

27 lines
504 B
Python
Raw Permalink 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.

'''
【程序8】
题目输出9*9口诀。
1.程序分析分行与列考虑共9行9列i控制行j控制列。
2.程序源代码:
#include "stdio.h"
main()
{
 int i,j,result;
 printf("\n");
 for (i=1;i<10;i++)
  { for(j=1;j<10;j++)
    {
     result=i*j;
     printf("%d*%d=%-3d",i,j,result);/*-3d表示左对齐占3位*/
    }
   printf("\n");/*每一行后换行*/
  }
}
'''
for i in range(1,10):
for j in range(1,10):
result = i * j
print '%d * %d = % -3d' % (i,j,result)
print ''