① 请编写一个程序,程序的功能是:从键盘输入一个整数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