---------------------------------------------------------
1: /*
2: 【程序1】
3: 题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
4: 1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。组成所有的排列后再去掉不满足条件的排列。
5: 2.程序源代码:
6: */
7: #include <stdio.h>
8: void main()
9: {
00401010 push ebp
00401011 mov ebp,esp
00401013 sub esp,4Ch
00401016 push ebx
00401017 push esi
00401018 push edi
00401019 lea edi,[ebp-4Ch]
0040101C mov ecx,13h
00401021 mov eax,0CCCCCCCCh
00401026 rep stos dword ptr [edi]
10: int i, j, k;
11: printf("\n");
00401028 push offset string "\n" (0042002c)
0040102D call printf (00401100)
00401032 add esp,4
12: for(i=1; i<5; i++) /*以下为三重循环*/
00401035 mov dword ptr [ebp-4],1
0040103C jmp main+37h (00401047)
0040103E mov eax,dword ptr [ebp-4]
00401041 add eax,1
00401044 mov dword ptr [ebp-4],eax
00401047 cmp dword ptr [ebp-4],5
0040104B jge main+0A4h (004010b4)
13: for(j=1; j<5; j++)
0040104D mov dword ptr [ebp-8],1
00401054 jmp main+4Fh (0040105f)
00401056 mov ecx,dword ptr [ebp-8]
00401059 add ecx,1
0040105C mov dword ptr [ebp-8],ecx
0040105F cmp dword ptr [ebp-8],5
00401063 jge main+0A2h (004010b2)
14: for(k=1; k<5; k++)
00401065 mov dword ptr [ebp-0Ch],1
0040106C jmp main+67h (00401077)
0040106E mov edx,dword ptr [ebp-0Ch]
00401071 add edx,1
00401074 mov dword ptr [ebp-0Ch],edx
00401077 cmp dword ptr [ebp-0Ch],5
0040107B jge main+0A0h (004010b0)
15: {
16: if(i != k && i !=j && j != k) /* 确保i、j、k三位互不相同 */
0040107D mov eax,dword ptr [ebp-4]
00401080 cmp eax,dword ptr [ebp-0Ch]
00401083 je main+9Eh (004010ae)
00401085 mov ecx,dword ptr [ebp-4]
00401088 cmp ecx,dword ptr [ebp-8]
0040108B je main+9Eh (004010ae)
0040108D mov edx,dword ptr [ebp-8]
00401090 cmp edx,dword ptr [ebp-0Ch]
00401093 je main+9Eh (004010ae)
17: printf("%d, %d, %d\n", i, j, k);
00401095 mov eax,dword ptr [ebp-0Ch]
00401098 push eax
00401099 mov ecx,dword ptr [ebp-8]
0040109C push ecx
0040109D mov edx,dword ptr [ebp-4]
004010A0 push edx
004010A1 push offset string "%d, %d, %d\n" (0042001c)
004010A6 call printf (00401100)
004010AB add esp,10h
18: }
004010AE jmp main+5Eh (0040106e)
004010B0 jmp main+46h (00401056)
004010B2 jmp main+2Eh (0040103e)
19: }
004010B4 pop edi
004010B5 pop esi
004010B6 pop ebx
004010B7 add esp,4Ch
004010BA cmp ebp,esp
004010BC call __chkesp (00401180)
004010C1 mov esp,ebp
004010C3 pop ebp
004010C4 ret
--- No source file ----------------
1: /*
2: 【程序2】
3: 题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金
4: 1.程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。
5: 2.程序源代码:
6: */
7: #include<stdio.h>
8: void main()
9: {
00401010 push ebp
00401011 mov ebp,esp
00401013 sub esp,70h
00401016 push ebx
00401017 push esi
00401018 push edi
00401019 lea edi,[ebp-70h]
0040101C mov ecx,1Ch
00401021 mov eax,0CCCCCCCCh
00401026 rep stos dword ptr [edi]
10: long int i;
11: int bonus1, bonus2, bonus4, bonus6, bonus10, bonus;
12: scanf("%ld", &i);
00401028 lea eax,[ebp-4]
0040102B push eax
0040102C push offset string "%ld" (004260b4)
00401031 call scanf (00401280)
00401036 add esp,8
13: bonus1 = 100000 * 0.1;
00401039 mov dword ptr [ebp-8],2710h
14: bonus2 = bonus1 + 100000 * 0.75;
00401040 fild dword ptr [ebp-8]
00401043 fadd qword ptr [__real@8@400f927c000000000000 (004260a8)]
00401049 call __ftol (004013c8)
0040104E mov dword ptr [ebp-0Ch],eax
15: bonus4 = bonus2 + 200000 * 0.5;
00401051 fild dword ptr [ebp-0Ch]
00401054 fadd qword ptr [__real@8@400fc350000000000000 (00426098)]
0040105A call __ftol (004013c8)
0040105F mov dword ptr [ebp-10h],eax
16: bonus6 = bonus4 + 200000 * 0.3;
00401062 fild dword ptr [ebp-10h]
00401065 fadd qword ptr [__real@8@400eea60000000000000 (00426088)]
0040106B call __ftol (004013c8)
00401070 mov dword ptr [ebp-14h],eax
17: bonus10 = bonus6 + 400000 * 0.15;
00401073 fild dword ptr [ebp-14h]
00401076 fadd qword ptr [__real@8@400eea60000000000000 (00426088)]
0040107C call __ftol (004013c8)
00401081 mov dword ptr [ebp-18h],eax
18: if(i <= 100000)
00401084 cmp dword ptr [ebp-4],186A0h
0040108B jg main+93h (004010a3)
19: bonus = i * 0.1;
0040108D fild dword ptr [ebp-4]
00401090 fmul qword ptr [__real@8@3ffbccccccccccccd000 (00426078)]
00401096 call __ftol (004013c8)
0040109B mov dword ptr [ebp-1Ch],eax
20: else if(i <= 200000)
0040109E jmp main+16Bh (0040117b)
004010A3 cmp dword ptr [ebp-4],30D40h
004010AA jg main+0C3h (004010d3)
21: bonus = bonus1 + (i - 100000) * 0.075;
004010AC fild dword ptr [ebp-8]
004010AF mov ecx,dword ptr [ebp-4]
004010B2 sub ecx,186A0h
004010B8 mov dword ptr [ebp-20h],ecx
004010BB fild dword ptr [ebp-20h]
004010BE fmul qword ptr [__real@8@3ffb9999999999999800 (00426068)]
004010C4 faddp st(1),st
004010C6 call __ftol (004013c8)
004010CB mov dword ptr [ebp-1Ch],eax
22: else if(i <= 400000)
004010CE jmp main+16Bh (0040117b)
004010D3 cmp dword ptr [ebp-4],61A80h
004010DA jg main+0F0h (00401100)
23: bonus = bonus2 + (i - 200000) * 0.05;
004010DC fild dword ptr [ebp-0Ch]
004010DF mov edx,dword ptr [ebp-4]
004010E2 sub edx,30D40h
004010E8 mov dword ptr [ebp-24h],edx
004010EB fild dword ptr [ebp-24h]
004010EE fmul qword ptr [__real@8@3ffaccccccccccccd000 (00426058)]
004010F4 faddp st(1),st
004010F6 call __ftol (004013c8)
004010FB mov dword ptr [ebp-1Ch],eax
24: else if(i <= 600000)
004010FE jmp main+16Bh (0040117b)
00401100 cmp dword ptr [ebp-4],927C0h
00401107 jg main+11Ch (0040112c)
25: bonus = bonus4 + (i - 400000) * 0.03;
00401109 fild dword ptr [ebp-10h]
0040110C mov eax,dword ptr [ebp-4]
0040110F sub eax,61A80h
00401114 mov dword ptr [ebp-28h],eax
00401117 fild dword ptr [ebp-28h]
0040111A fmul qword ptr [__real@8@3ff9f5c28f5c28f5c000 (00426048)]
00401120 faddp st(1),st
00401122 call __ftol (004013c8)
00401127 mov dword ptr [ebp-1Ch],eax
26: else if(i <= 1000000)
0040112A jmp main+16Bh (0040117b)
0040112C cmp dword ptr [ebp-4],0F4240h
00401133 jg main+149h (00401159)
27: bonus = bonus6 + (i - 600000) * 0.015;
00401135 fild dword ptr [ebp-14h]
00401138 mov ecx,dword ptr [ebp-4]
0040113B sub ecx,927C0h
00401141 mov dword ptr [ebp-2Ch],ecx
00401144 fild dword ptr [ebp-2Ch]
00401147 fmul qword ptr [__real@8@3ff8f5c28f5c28f5c000 (00426038)]
0040114D faddp st(1),st
0040114F call __ftol (004013c8)
00401154 mov dword ptr [ebp-1Ch],eax
28: else
00401157 jmp main+16Bh (0040117b)
29: bonus = bonus10 + (i - 1000000) * 0.01;
00401159 fild dword ptr [ebp-18h]
0040115C mov edx,dword ptr [ebp-4]
0040115F sub edx,0F4240h
00401165 mov dword ptr [ebp-30h],edx
00401168 fild dword ptr [ebp-30h]
0040116B fmul qword ptr [__real@8@3ff8a3d70a3d70a3d800 (00426028)]
00401171 faddp st(1),st
00401173 call __ftol (004013c8)
00401178 mov dword ptr [ebp-1Ch],eax
30: printf("bonus=%d", bonus);
0040117B mov eax,dword ptr [ebp-1Ch]
0040117E push eax
0040117F push offset string "bonus=%d" (0042601c)
00401184 call printf (00401200)
00401189 add esp,8
31: }
0040118C pop edi
0040118D pop esi
0040118E pop ebx
0040118F add esp,70h
00401192 cmp ebp,esp
00401194 call __chkesp (00401390)
00401199 mov esp,ebp
0040119B pop ebp
0040119C ret
--- No source file ------------------------------------------------
1: /*
2: 【程序3】
3: 题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?
4: 1.程序分析:在10万以内判断,先将该数加上100后再开方,再将该数加上268后再开方,如果开方后的结果满足如下条件,即是结果。请看具体分析:
5: 2.程序源代码:
6: */
7: #include <math.h>
8: #include <stdio.h>
9: main()
10: {
00401010 push ebp
00401011 mov ebp,esp
00401013 sub esp,58h
00401016 push ebx
00401017 push esi
00401018 push edi
00401019 lea edi,[ebp-58h]
0040101C mov ecx,16h
00401021 mov eax,0CCCCCCCCh
00401026 rep stos dword ptr [edi]
11: long int i, x, y, z;
12: for(i=1; i<100000; i++)
00401028 mov dword ptr [ebp-4],1
0040102F jmp main+2Ah (0040103a)
00401031 mov eax,dword ptr [ebp-4]
00401034 add eax,1
00401037 mov dword ptr [ebp-4],eax
0040103A cmp dword ptr [ebp-4],186A0h
00401041 jge main+0B8h (004010c8)
13: {
14: x = sqrt(i + 100); /* x为加上100后开方后的结果 */
00401047 mov ecx,dword ptr [ebp-4]
0040104A add ecx,64h
0040104D mov dword ptr [ebp-14h],ecx
00401050 fild dword ptr [ebp-14h]
00401053 sub esp,8
00401056 fstp qword ptr [esp]
00401059 call _sqrt (004011a4)
0040105E add esp,8
00401061 call __ftol (00401338)
00401066 mov dword ptr [ebp-8],eax
15: y = sqrt(i + 268); /* y为再加上168后开方后的结果 */
00401069 mov edx,dword ptr [ebp-4]
0040106C add edx,10Ch
00401072 mov dword ptr [ebp-18h],edx
00401075 fild dword ptr [ebp-18h]
00401078 sub esp,8
0040107B fstp qword ptr [esp]
0040107E call _sqrt (004011a4)
00401083 add esp,8
00401086 call __ftol (00401338)
0040108B mov dword ptr [ebp-0Ch],eax
16: //
17: /* 如果一个数的平方根的平方等于该数,这说明此数是完全平方数 */
18: if(x * x == i + 100 && y * y == i + 268)
0040108E mov eax,dword ptr [ebp-8]
00401091 imul eax,dword ptr [ebp-8]
00401095 mov ecx,dword ptr [ebp-4]
00401098 add ecx,64h
0040109B cmp eax,ecx
0040109D jne main+0B3h (004010c3)
0040109F mov edx,dword ptr [ebp-0Ch]
004010A2 imul edx,dword ptr [ebp-0Ch]
004010A6 mov eax,dword ptr [ebp-4]
004010A9 add eax,10Ch
004010AE cmp edx,eax
004010B0 jne main+0B3h (004010c3)
19: printf("\n%ld\n", i);
004010B2 mov ecx,dword ptr [ebp-4]
004010B5 push ecx
004010B6 push offset string "\n%ld\n" (0042501c)
004010BB call printf (00401110)
004010C0 add esp,8
20: }
004010C3 jmp main+21h (00401031)
21: }
004010C8 pop edi
004010C9 pop esi
004010CA pop ebx
004010CB add esp,58h
004010CE cmp ebp,esp
004010D0 call __chkesp (00401300)
004010D5 mov esp,ebp
004010D7 pop ebp
004010D8 ret
--- No source file --------------------------------
1: /*
2: 【程序4】
3: 题目:输入某年某月某日,判断这一天是这一年的第几天?
4: 1.程序分析:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且输入月份大于3时需考虑多加一天。
5: 2.程序源代码:
6: */
7: #include <stdio.h>
8:
9: main()
10: {
00410070 push ebp
00410071 mov ebp,esp
00410073 sub esp,58h
00410076 push ebx
00410077 push esi
00410078 push edi
00410079 lea edi,[ebp-58h]
0041007C mov ecx,16h
00410081 mov eax,0CCCCCCCCh
00410086 rep stos dword ptr [edi]
11: int day, month, year, sum, leap;
12: printf("\nplease input year, month, day\n");
00410088 push offset string "\nplease input year, month, day\n" (00426104)
0041008D call printf (00401110)
00410092 add esp,4
13: scanf("%d, %d, %d", &year, &month, &day);
00410095 lea eax,[ebp-4]
00410098 push eax
00410099 lea ecx,[ebp-8]
0041009C push ecx
0041009D lea edx,[ebp-0Ch]
004100A0 push edx
004100A1 push offset string "%d, %d, %d" (004260f8)
004100A6 call scanf (004123f0)
004100AB add esp,10h
14: switch(month) /* 先计算某月以前月份的总天数 */
15: {
004100AE mov eax,dword ptr [ebp-8]
004100B1 mov dword ptr [ebp-18h],eax
004100B4 mov ecx,dword ptr [ebp-18h]
004100B7 sub ecx,1
004100BA mov dword ptr [ebp-18h],ecx
004100BD cmp dword ptr [ebp-18h],0Bh
004100C1 ja $L548+9 (00410139)
004100C3 mov edx,dword ptr [ebp-18h]
004100C6 jmp dword ptr [edx*4+4101C8h]
16: case 1: sum=0; break;
004100CD mov dword ptr [ebp-10h],0
004100D4 jmp $L548+16h (00410146)
17: case 2: sum=31; break;
004100D6 mov dword ptr [ebp-10h],1Fh
004100DD jmp $L548+16h (00410146)
18: case 3: sum=59; break;
004100DF mov dword ptr [ebp-10h],3Bh
004100E6 jmp $L548+16h (00410146)
19: case 4: sum=90; break;
004100E8 mov dword ptr [ebp-10h],5Ah
004100EF jmp $L548+16h (00410146)
20: case 5: sum=120; break;
004100F1 mov dword ptr [ebp-10h],78h
004100F8 jmp $L548+16h (00410146)
21: case 6: sum=151; break;
004100FA mov dword ptr [ebp-10h],97h
00410101 jmp $L548+16h (00410146)
22: case 7: sum=181; break;
00410103 mov dword ptr [ebp-10h],0B5h
0041010A jmp $L548+16h (00410146)
23: case 8: sum=212; break;
0041010C mov dword ptr [ebp-10h],0D4h
00410113 jmp $L548+16h (00410146)
24: case 9: sum=243; break;
00410115 mov dword ptr [ebp-10h],0F3h
0041011C jmp $L548+16h (00410146)
25: case 10: sum=273; break;
0041011E mov dword ptr [ebp-10h],111h
00410125 jmp $L548+16h (00410146)
26: case 11: sum=304; break;
00410127 mov dword ptr [ebp-10h],130h
0041012E jmp $L548+16h (00410146)
27: case 12: sum=334; break;
00410130 mov dword ptr [ebp-10h],14Eh
00410137 jmp $L548+16h (00410146)
28: default: printf("data error");break;
00410139 push offset string "data error" (004260ec)
0041013E call printf (00401110)
00410143 add esp,4
29: }
30: sum = sum + day; /* 再加上某天的天数 */
00410146 mov eax,dword ptr [ebp-10h]
00410149 add eax,dword ptr [ebp-4]
0041014C mov dword ptr [ebp-10h],eax
31: if(year %400 == 0 || (year % 4 == 0 && year % 100 != 0)) /* 判断是不是闰年 */
0041014F mov eax,dword ptr [ebp-0Ch]
00410152 cdq
00410153 mov ecx,190h
00410158 idiv eax,ecx
0041015A test edx,edx
0041015C je $L548+51h (00410181)
0041015E mov edx,dword ptr [ebp-0Ch]
00410161 and edx,80000003h
00410167 jns $L548+3Eh (0041016e)
00410169 dec edx
0041016A or edx,0FCh
0041016D inc edx
0041016E test edx,edx
00410170 jne $L548+5Ah (0041018a)
00410172 mov eax,dword ptr [ebp-0Ch]
00410175 cdq
00410176 mov ecx,64h
0041017B idiv eax,ecx
0041017D test edx,edx
0041017F je $L548+5Ah (0041018a)
32: leap = 1;
00410181 mov dword ptr [ebp-14h],1
33: else
00410188 jmp $L548+61h (00410191)
34: leap = 0;
0041018A mov dword ptr [ebp-14h],0
35: if(leap == 1 && month > 2) /* 如果是闰年且月份大于2, 总天数应该加一天 */
00410191 cmp dword ptr [ebp-14h],1
00410195 jne $L548+76h (004101a6)
00410197 cmp dword ptr [ebp-8],2
0041019B jle $L548+76h (004101a6)
36: sum++;
0041019D mov edx,dword ptr [ebp-10h]
004101A0 add edx,1
004101A3 mov dword ptr [ebp-10h],edx
37: printf("It is the %dth day.", sum);
004101A6 mov eax,dword ptr [ebp-10h]
004101A9 push eax
004101AA push offset string "It is the %dth day." (004260d8)
004101AF call printf (00401110)
004101B4 add esp,8
38: }
004101B7 pop edi
004101B8 pop esi
004101B9 pop ebx
004101BA add esp,58h
004101BD cmp ebp,esp
004101BF call __chkesp (00401300)
004101C4 mov esp,ebp
004101C6 pop ebp
004101C7 ret
004101C8 int 0
004101CA inc ecx
004101CB add dh,dl
004101CD add byte ptr [ecx],al
004101D0 fild word ptr [eax]
004101D2 inc ecx
004101D3 add al,ch
004101D5 add byte ptr [ecx],al
004101D8 ???
004101D9 add byte ptr [ecx],al
004101DC cli
004101DD add byte ptr [ecx],al
004101E0 add eax,dword ptr [ecx]
004101E2 inc ecx
004101E3 add byte ptr [ecx+eax],cl
004101E6 inc ecx
004101E7 add byte ptr ds:[1E004101h],dl
004101ED add dword ptr [ecx],eax
004101F0 daa
004101F1 add dword ptr [ecx],eax
004101F4 xor byte ptr [ecx],al
004101F6 inc ecx
004101F7 add ah,cl
--- No source file -----------------------------------------------------
1: /*
2: 【程序5】
3: 题目:输入三个整数x, y, z,请把这三个数由小到大输出。
4: 1.程序分析:我们想办法把最小的数放到x上,先将x与y进行比较,如果x>y则将x与y的值进行交换,然后再用x与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最? ?
5: 2.程序源代码:
6: */
7: #include <stdio.h>
8:
9: main()
10: {
00401010 push ebp
00401011 mov ebp,esp
00401013 sub esp,50h
00401016 push ebx
00401017 push esi
00401018 push edi
00401019 lea edi,[ebp-50h]
0040101C mov ecx,14h
00401021 mov eax,0CCCCCCCCh
00401026 rep stos dword ptr [edi]
11: int x, y, z, t;
12: scanf("%d%d%d", &x, &y, &z);
00401028 lea eax,[ebp-0Ch]
0040102B push eax
0040102C lea ecx,[ebp-8]
0040102F push ecx
00401030 lea edx,[ebp-4]
00401033 push edx
00401034 push offset string "%d%d%d" (00422038)
00401039 call scanf (00401170)
0040103E add esp,10h
13: if(x>y)
00401041 mov eax,dword ptr [ebp-4]
00401044 cmp eax,dword ptr [ebp-8]
00401047 jle main+4Bh (0040105b)
14: {
15: t = x; x = y; y = t;
00401049 mov ecx,dword ptr [ebp-4]
0040104C mov dword ptr [ebp-10h],ecx
0040104F mov edx,dword ptr [ebp-8]
00401052 mov dword ptr [ebp-4],edx
00401055 mov eax,dword ptr [ebp-10h]
00401058 mov dword ptr [ebp-8],eax
16: } /* 交换x, y的值 */
17: if(x > z)
0040105B mov ecx,dword ptr [ebp-4]
0040105E cmp ecx,dword ptr [ebp-0Ch]
00401061 jle main+65h (00401075)
18: {
19: t = z; z = x; x = t;
00401063 mov edx,dword ptr [ebp-0Ch]
00401066 mov dword ptr [ebp-10h],edx
00401069 mov eax,dword ptr [ebp-4]
0040106C mov dword ptr [ebp-0Ch],eax
0040106F mov ecx,dword ptr [ebp-10h]
00401072 mov dword ptr [ebp-4],ecx
20: } /* 交换x, z的值 */
21: if(y > z)
00401075 mov edx,dword ptr [ebp-8]
00401078 cmp edx,dword ptr [ebp-0Ch]
0040107B jle main+7Fh (0040108f)
22: {
23: t = y; y = z; z = t;
0040107D mov eax,dword ptr [ebp-8]
00401080 mov dword ptr [ebp-10h],eax
00401083 mov ecx,dword ptr [ebp-0Ch]
00401086 mov dword ptr [ebp-8],ecx
00401089 mov edx,dword ptr [ebp-10h]
0040108C mov dword ptr [ebp-0Ch],edx
24: } /* 交换z, y的值 */
25: printf("small to big: %d %d %d\n", x, y, z);
0040108F mov eax,dword ptr [ebp-0Ch]
00401092 push eax
00401093 mov ecx,dword ptr [ebp-8]
00401096 push ecx
00401097 mov edx,dword ptr [ebp-4]
0040109A push edx
0040109B push offset string "small to big: %d %d %d\n" (0042201c)
004010A0 call printf (004010f0)
004010A5 add esp,10h
26: }
004010A8 pop edi
004010A9 pop esi
004010AA pop ebx
004010AB add esp,50h
004010AE cmp ebp,esp
004010B0 call __chkesp (004011d0)
004010B5 mov esp,ebp
004010B7 pop ebp
004010B8 ret
--- No source file ------------------------------
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课