请用Visual FoxPro写一个用*号生成爱心的程序代码
时间: 2024-05-29 07:08:22 浏览: 46
以下是用Visual FoxPro编写的生成爱心的程序代码:
CLEAR
SET SAFETY OFF
SET CONSOLE OFF
SET ESCAPE OFF
SET NOTIFY OFF
* 定义变量
LOCAL i, j, k
* 清屏
CLS
* 循环输出星号
FOR i = 1 TO 6
FOR j = 1 TO 7
k = ABS(i - 4)
IF k = 0
k = ABS(j - 4)
ELSE
k = ABS(j - 4) * 2 / k
ENDIF
IF k > 0.6
? "*";
ELSE
? " ";
ENDIF
ENDFOR
? CHR(13)
ENDFOR
* 输出换行
? CHR(13)
* 循环输出星号
FOR i = 1 TO 6
FOR j = 1 TO 7
k = ABS(i - 4)
IF k = 0
k = ABS(j - 4)
ELSE
k = ABS(j - 4) * 2 / k
ENDIF
IF k > 0.6 AND j > 2 AND j < 6
? " ";
ELSE
? "*";
ENDIF
ENDFOR
? CHR(13)
ENDFOR
* 输出换行
? CHR(13)
* 循环输出星号
FOR i = 1 TO 6
FOR j = 1 TO 7
k = ABS(i - 4)
IF k = 0
k = ABS(j - 4)
ELSE
k = ABS(j - 4) * 2 / k
ENDIF
IF k > 0.6 AND ((j = 1 AND i < 4) OR (j = 7 AND i < 4) OR (j > 1 AND j < 7 AND k < 0.5 AND i > 2)))
? " ";
ELSE
? "*";
ENDIF
ENDFOR
? CHR(13)
ENDFOR
* 输出换行
? CHR(13)
* 循环输出星号
FOR i = 1 TO 6
FOR j = 1 TO 7
k = ABS(i - 4)
IF k = 0
k = ABS(j - 4)
ELSE
k = ABS(j - 4) * 2 / k
ENDIF
IF k > 0.6 AND ((j = 1 AND i < 4) OR (j = 7 AND i < 4) OR (j > 1 AND j < 7 AND k < 0.5 AND i > 2)) OR (i = 4 AND j > 1 AND j < 7)
? " ";
ELSE
? "*";
ENDIF
ENDFOR
? CHR(13)
ENDFOR
* 输出换行
? CHR(13)
* 循环输出星号
FOR i = 1 TO 6
FOR j = 1 TO 7
k = ABS(i - 4)
IF k = 0
k = ABS(j - 4)
ELSE
k = ABS(j - 4) * 2 / k
ENDIF
IF k > 0.6 AND ((j = 1 AND i < 4) OR (j = 7 AND i < 4) OR (j > 1 AND j < 7 AND k < 0.5 AND i > 2)) OR (i = 4 AND j > 1 AND j < 7) OR (i = 5 AND j > 2 AND j < 6)
? " ";
ELSE
? "*";
ENDIF
ENDFOR
? CHR(13)
ENDFOR
* 输出换行
? CHR(13)
* 循环输出星号
FOR i = 1 TO 6
FOR j = 1 TO 7
k = ABS(i - 4)
IF k = 0
k = ABS(j - 4)
ELSE
k = ABS(j - 4) * 2 / k
ENDIF
IF k > 0.6 AND ((j = 1 AND i < 4) OR (j = 7 AND i < 4) OR (j > 1 AND j < 7 AND k < 0.5 AND i > 2)) OR (i = 4 AND j > 1 AND j < 7) OR (i = 5 AND j > 2 AND j < 6) OR (i = 6 AND j = 4)
? " ";
ELSE
? "*";
ENDIF
ENDFOR
? CHR(13)
ENDFOR
* 输出换行
? CHR(13)
* 关闭程序
RETURN
阅读全文