1.c語言的編程,if else的語句
scanf("%d",y);
這個改成scanf("%d",&y);
if(y%4=0)改成 if(y%4==0)
另外 判斷閏年算法不對 還得考慮如果是100的倍數 但不是400的倍數 那么也不是閏年
所以可以
if(y%400==0 || (y%100!=0 && y %4==0))
printf("This year is leap year.");
else
printf("This year is not a leap year.");
2.求簡短程序代碼
彈球游戲代碼,供參考:
控件:shape兩個,timer1個
Private Sub Timer1_Timer()
Static a, b
If * <= * Then
a = 15
End If
If * <= * Then
b = 15
End If
If * >= * + * - * Then
a = -15
End If
If * >= * + * - * Then
b = -15
End If
* * + a, * + b
End Sub
Private Sub Form_Load()
*al=10
* = 2900
* = 3300
With Shape1:
.Top = 100
.Left = 100
.Width = 2500
.Height = 2700
End With
With Shape2:
.Top = 100
.Left = 100
.Shape = 3
.Width = 400
.FillStyle = 0
End With
a = 15: b = 15
End Sub
3.寫一個簡短的C語言代碼
#include <stdio.h>
int main()
{
權double a,b,c;
scanf("%lf",&a);
scanf("%lf",&b);
c=a+b;
printf("first number:%.2lf",a);
printf("\nsecond number%.2lf",b);
printf("\n\t%.2lf",a);
printf("\n+\t%.2lf",b);
printf("\n-------------\n");
printf(" %.2lf\n",c);
return 0;
}
4.簡單的編程~寫出代碼就行~
Private Sub Command1_Click()
Print "這些數為:"
For i = 101 To 199
For j = 2 To i - 1
If i Mod j = 0 Then
Exit For
End If
Next
If s Mod 10 = 0 Then Print '每行打印十個數
If j = i Then
Print i;
a = a + i
s = s + 1
End If
Next
Print "這些數的和為:" & a
End Sub
可以直接運行,希望能幫助到你