|
30鱼币
本帖最后由 欣欣celin 于 2014-5-1 18:35 编辑 //本程序要实现查找,其中有不及格课程的学生,并打印其学号
#include "stdio.h"
void main()
{
double score[][4]={{60.0,70.0,80.5,90.5},{56.0,89.0,67.0,88.0},{34.2,78.5,90.0,70.5},{67.5,90.5,43.0,78.5}};
int i, j;
for(i=0; score[i][j] != '\0'; i++)
{
for(j=0; score[i][j] != '\0'; j++)
{
if(score[i][j] < 60.0)
{
printf("score[%d][%d]", i, j);
}
}
}
}
以上写法怪怪的,CUP看了肯定2死了,可偶还不知错在哪了
调试如下,
3: #include "stdio.h"
4: void main()
5: {
00401020 push ebp
00401021 mov ebp,esp
00401023 sub esp,0C8h
00401029 push ebx
0040102A push esi
0040102B push edi
0040102C lea edi,[ebp-0C8h]
00401032 mov ecx,32h
00401037 mov eax,0CCCCCCCCh
0040103C rep stos dword ptr [edi]
6: double score[][4]={{60.0,70.0,80.5,90.5},{56.0,89.0,67.0,88.0},{34.2,78.5,90.0,70.5},{67.5,90.5,43.0,78.5}};
0040103E mov dword ptr [ebp-80h],0
00401045 mov dword ptr [ebp-7Ch],404E0000h
0040104C mov dword ptr [ebp-78h],0
00401053 mov dword ptr [ebp-74h],40518000h
0040105A mov dword ptr [ebp-70h],0
00401061 mov dword ptr [ebp-6Ch],40542000h
00401068 mov dword ptr [ebp-68h],0
0040106F mov dword ptr [ebp-64h],4056A000h
00401076 mov dword ptr [ebp-60h],0
0040107D mov dword ptr [ebp-5Ch],404C0000h
00401084 mov dword ptr [ebp-58h],0
0040108B mov dword ptr [ebp-54h],40564000h
00401092 mov dword ptr [ebp-50h],0
00401099 mov dword ptr [ebp-4Ch],4050C000h
004010A0 mov dword ptr [ebp-48h],0
004010A7 mov dword ptr [ebp-44h],40560000h
004010AE mov dword ptr [ebp-40h],9999999Ah
004010B5 mov dword ptr [ebp-3Ch],40411999h
004010BC mov dword ptr [ebp-38h],0
004010C3 mov dword ptr [ebp-34h],4053A000h
004010CA mov dword ptr [ebp-30h],0
004010D1 mov dword ptr [ebp-2Ch],40568000h
004010D8 mov dword ptr [ebp-28h],0
004010DF mov dword ptr [ebp-24h],4051A000h
004010E6 mov dword ptr [ebp-20h],0
004010ED mov dword ptr [ebp-1Ch],4050E000h
004010F4 mov dword ptr [ebp-18h],0
004010FB mov dword ptr [ebp-14h],4056A000h
00401102 mov dword ptr [ebp-10h],0
00401109 mov dword ptr [ebp-0Ch],40458000h
00401110 mov dword ptr [ebp-8],0
00401117 mov dword ptr [ebp-4],4053A000h
7:
8: int i, j;
9:
10: for(i=0; score[j] != '\0'; i++)
0040111E mov dword ptr [ebp-84h],0
00401128 jmp main+119h (00401139)
0040112A mov eax,dword ptr [ebp-84h]
00401130 add eax,1
00401133 mov dword ptr [ebp-84h],eax
00401139 mov ecx,dword ptr [ebp-84h]
0040113F shl ecx,5
00401142 lea edx,[ebp+ecx-80h]
00401146 mov eax,dword ptr [ebp-88h]
0040114C fld qword ptr [edx+eax*8]
//运行到此,弹出对话框“unhandled exception in score.exe: 0xc0000005: access voilation",为什么?? 如何改才正确?
0040114F fcomp qword ptr [__real@8@00000000000000000000 (004294d8)]
00401155 fnstsw ax
00401157 test ah,40h
0040115A jne main+1C3h (004011e3)
11: {
12: for(j=0; score[j] != '\0'; j++)
00401160 mov dword ptr [ebp-88h],0
0040116A jmp main+15Bh (0040117b)
0040116C mov ecx,dword ptr [ebp-88h]
00401172 add ecx,1
00401175 mov dword ptr [ebp-88h],ecx
0040117B mov edx,dword ptr [ebp-84h]
00401181 shl edx,5
00401184 lea eax,[ebp+edx-80h]
00401188 mov ecx,dword ptr [ebp-88h]
0040118E fld qword ptr [eax+ecx*8]
00401191 fcomp qword ptr [__real@8@00000000000000000000 (004294d8)]
00401197 fnstsw ax
00401199 test ah,40h
0040119C jne main+1BEh (004011de)
13: {
14: if(score[j] < 60.0)
0040119E mov edx,dword ptr [ebp-84h]
004011A4 shl edx,5
004011A7 lea eax,[ebp+edx-80h]
004011AB mov ecx,dword ptr [ebp-88h]
004011B1 fld qword ptr [eax+ecx*8]
004011B4 fcomp qword ptr [__real@8@4004f000000000000000 (0042a0c0)]
004011BA fnstsw ax
004011BC test ah,1
004011BF je main+1BCh (004011dc)
15: {
16: printf("score[%d][%d]", i, j);
004011C1 mov edx,dword ptr [ebp-88h]
004011C7 push edx
004011C8 mov eax,dword ptr [ebp-84h]
004011CE push eax
004011CF push offset string "score[%d][%d]" (0042a0b0)
004011D4 call printf (004012f0)
004011D9 add esp,0Ch
17: }
18: }
004011DC jmp main+14Ch (0040116c)
19: }
004011DE jmp main+10Ah (0040112a)
20:
21: }
004011E3 pop edi
004011E4 pop esi
004011E5 pop ebx
004011E6 add esp,0C8h
004011EC cmp ebp,esp
004011EE call __chkesp (00401420)
004011F3 mov esp,ebp
004011F5 pop ebp
004011F6 ret
//还有,本题原本是要求用指针函数来解的,可是怎么也写不出来,越学越蒙了,咋办呐??
|
|