C语言编程小问题

[复制链接]
查看11 | 回复1 | 2009-7-23 16:50:40 | 显示全部楼层 |阅读模式
哪位高手帮忙看一下,编译没问题。运行不出来。
只求看一下是那个地方错了,而不是要一个对的,请高手帮忙!
代码如下:
#include "stdafx.h"
#include"stdio.h"
int he(int a[99],int n)
{ int m;
int *p,i=0;
p=a;
for (p=a;p<a+n;p++)
{
printf("input a[%d]:\n",i++);
scanf("%d\n",p);
}
i=0;
p=a;
m=a[0];
for (p=a;p<a+n;p++)
{

m=m+a;
}
return m;
}
void main ()
{
int n,a[99],m;
printf("input the size of the shuzu what can't be larger then 100\n");
scanf("%d",&n);
m=he(a,n);
printf("the he of what you input is:%d\n",m);
}
另外,调试信息如下:
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
The thread 0x9A24 has exited with code 32 (0x20).
The program 'C:\Program Files\Microsoft Visual Studio\MyProjects\zhizhen2\Debug\zhizhen2.exe' has exited with code 32 (0x20).
谢谢!

回复

使用道具 举报

千问 | 2009-7-23 16:50:40 | 显示全部楼层
int he(int a[99],int n){ int m; int *p,i=0; p=a; for (p=a;p<a+n;p++){printf("input a[%d]:\n",i++);scanf("%d",p); //这里最好不要加\n } i=0; p=a; m=0; //和应该初始化为0,因为你后面又加了一次a[0] for (p=a;p<a+n;p++) {
m=m+*p; //这里,你原来加的a,但i一直没变过 } return m;}...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行