① 請編寫一個程序,程序的功能是:從鍵盤輸入一個整數m,求出1到m(含m)能被7或11整除的所有整數,
#include<stdio.h>
voidmain()
{
intm,k=0,i;
printf("請輸入正整數m的值:");
scanf("%d",&m);
for(i=2;i<=m;i++)
if(i%7==0||i%11==0)
{
printf("%d",i);
k++;
}
printf(" 1到%d之間能被7或11整除的數共有%d個。 ",m,k);
}
運行示例:
② 一下程序為什麼輸出結果是1122
a=0x03 0000 0011
b = a | 0x8 0000 0011 | 0000 1000 = 0000 1011 =0x0b = 11
c = b << 1 0001 0110 = 0x16 = 22
所以就是1122
③ 求大神詳細解釋下這個程序,謝謝
輸出1122
new的時候執行構造函數,輸出「1」,因為是2個元素所以輸出2次——「11」
delete時執行析構函數,輸出「2」,同理,2個元素,輸出2次——「22」
④ 用VB語言編寫輸入出生日期算出生肖與星座的程序
'新建窗體form1
'添加控制項 DTPicker1,Command1
Private Sub Command1_Click()
Dim aa As Integer
Dim bb As Integer
Dim cc As Integer
Dim dd_xingzuo As Integer
Dim dd_shengxiao As Integer
Dim leirong As String
bb = DTPicker1.Month
aa = DTPicker1.Day
cc = DTPicker1.Year
dd_xingzuo = (bb * 100 + aa)
dd_shengxiao = cc Mod 12
If dd_xingzuo > 112 And dd_xingzuo < 221 Then
leirong = "星座:水瓶座"
End If
If dd_xingzuo >= 221 And dd_xingzuo <= 321 Then
leirong = "星座:雙魚座"
End If
If dd_xingzuo >= 322 And dd_xingzuo <= 420 Then
leirong = "星座:白羊座"
End If
If dd_xingzuo >= 421 And dd_xingzuo <= 521 Then
leirong = "星座:金牛座"
End If
If dd_xingzuo >= 522 And dd_xingzuo <= 621 Then
leirong = "星座:雙子座"
End If
If dd_xingzuo >= 622 And dd_xingzuo <= 721 Then
leirong = "星座:巨蟹座"
End If
If dd_xingzuo >= 722 And dd_xingzuo <= 821 Then
leirong = "星座:獅子坐"
End If
If dd_xingzuo >= 822 And dd_xingzuo <= 921 Then
leirong = "星座:處女座"
End If
If dd_xingzuo >= 922 And dd_xingzuo <= 1021 Then
leirong = "星座:天秤座"
End If
If dd_xingzuo >= 1022 And dd_xingzuo <= 1121 Then
leirong = "星座:天蠍座"
End If
If dd_xingzuo >= 1122 And dd_xingzuo <= 1221 Then
leirong = "星座:射手座"
End If
If dd_xingzuo >= 1222 Or dd_xingzuo <= 111 Then
leirong = "星座:摩羯座"
End If
Select Case dd_shengxiao
Case 0
leirong = leirong & vbCrLf & "身肖:猴"
Case 1
leirong = leirong & vbCrLf & "身肖:雞"
Case 2
leirong = leirong & vbCrLf & "身肖:狗"
Case 3
leirong = leirong & vbCrLf & "身肖:豬"
Case 4
leirong = leirong & vbCrLf & "身肖:鼠"
Case 5
leirong = leirong & vbCrLf & "身肖:牛"
Case 6
leirong = leirong & vbCrLf & "身肖:虎"
Case 7
leirong = leirong & vbCrLf & "身肖:兔"
Case 8
leirong = leirong & vbCrLf & "身肖:龍"
Case 9
leirong = leirong & vbCrLf & "身肖:蛇"
Case 10
leirong = leirong & vbCrLf & "身肖:馬"
Case 11
leirong = leirong & vbCrLf & "身肖:羊"
End Select
MsgBox leirong, vbInformation, "計算結果"
End Sub