代码设计的原则包括唯一确定性、标准化和通用性、可扩充性与稳定性、便于识别与记忆、力求短小与格式统一以及容易修改等。源代码是代码的分支,某种意义上来说,源代码相当于代码。现代程序语言中,源代码可以书籍或磁带形式出现,但最为常用格式是文本文件,这种典型格式的目的是为了编译出计算机程序。
创建一个心形图案需要的最长字符串,充分利用printf函数输出字符串的丰富控制功能,按心形图案每行所需长度和位置,对所创建的字符串进行截断并在所需位置上输出,最后在屏幕上形成由字符组成的心形图案。//#include "stdafx.h"//If the vc++6.0, with this line.
#include "stdio.h"
int main(void){
char a[]="I love you I love you I love you I l"
printf("\n\n\n")
printf("%*.*s\n",58,21,"_*=_ _=*_")
printf("%*.*s\n",61,25,"I love yo u I love!")
printf("%*.*s\n",63,29,"I love you I l ove you I love")
printf("%*.*s\n",65,33,a)//在屏幕第65个字符处开始输出字符串a的前33个字符,其他各句意义相同
printf("%*.*s\n",66,35,a)
printf("%*.*s\n",66,35,a)
printf("%*.*s\n",65,33,a)
printf("%*.*s\n",64,31,a)
printf("%*.*s\n",63,29,a)
printf("%*.*s\n",61,25,a)
printf("%*.*s\n",59,21,a)
printf("%*.*s\n",57,17,a)
printf("%*.*s\n",55,13,a)
printf("%*.*s\n",53,9,a)
printf("%*.*s\n",51,5,a)
printf("%*.*s\n",50,3,a)
printf("%*.*s\n",49,1,a)
return 0
}
Dim X1, Y1, X2, Y2 As IntegerDim I As Integer
Dim J As Boolean
Dim K As IntegerDim WithEvents Label1 As Label
Dim WithEvents Timer1 As TimerPrivate Sub Form_Activate()
I = 100
K = 100
X1 = Me.Width / 2
Y1 = Me.Height / 3
X2 = X1
Y2 = Y1
Label1.Top = Me.Height / 2 - Label1.Height / 2
Label1.Left = Me.Width / 2 - Label1.Width / 2
End SubPrivate Sub Form_Load() Me.BackColor = &H0&
Me.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.DrawMode = 13
Me.DrawWidth = 2
Me.FillStyle = 7
Set Label1 = Me.Controls.Add("VB.Label", "Label1")
Set Timer1 = Me.Controls.Add("VB.Timer", "Timer1")
Label1.Visible = True
Label1.AutoSize = True
Label1.BackStyle = 0
Label1.Caption = "I LOVE YOU"
Label1.Font.Size = 60
Label1.ForeColor = &HFF00&
Timer1.Enabled = True
Timer1.Interval = 10
Me.WindowState = 2
End SubPrivate Sub Timer1_Timer()
Me.Circle (X1, Y1), 250
Me.Circle (X2, Y2), 250
If Y1 <= Me.Height - 1200 Then
X1 = X1 + K
Y1 = Y1 - I
X2 = X2 - K
Y2 = Y2 - I
I = I - 2
If Y1 <= Me.Height / 3 Then
K = K - 1
ElseIf Y1 >= Me.Height / 3 Then
K = K - 5
End If
Else
I = 100
K = 100
X1 = Me.Width / 2
Y1 = Me.Height / 3
X2 = X1
Y2 = Y1
Me.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255) End If
Me.DrawWidth = 3
Me.PSet (Rnd * Me.Width, Rnd * Me.Height), RGB(Rnd * 225, Rnd * 225, Rnd * 225)
Me.DrawWidth = 2
End SubPrivate Sub Form_Click()
End
End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
End
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)