帮忙写一个小测试程序

[复制链接]
查看11 | 回复1 | 2008-6-18 23:59:16 | 显示全部楼层 |阅读模式
帮忙写一个小程序测试一下下面这个找出数组中最大数字位置的程序
int findMax(int *a, int len)
{
int i,position;
if (len==0)
{
return 0
}
else
{
position = 0;
}
for(i=1;i<len;i++)
{
if(a[position]<a)
{
position = i;
}
}
return position
}
测试程序:int main (int argc, char *argv[])

回复

使用道具 举报

千问 | 2008-6-18 23:59:16 | 显示全部楼层
// test.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "stdlib.h"#include "string.h"int findMax(int *a, int len) { int i,position; if (len==0) { return 0; } else { position = 0; } for(i=1;i<len;i++) { if(a[position]<a) { position = i; }
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行