C语言改错题0004--难度3(综合)

题目要求:

从键盘输入某单位职工的月收入(人数最多不超过40人),当输入负值时,表示输入结束,编程从键盘任意输入一个职工号,查找该职工的月收入。

程序如下,请修正程序中的错误,使之能够得到正确的运行结果。

题目代码: 

#include 
#define N 40
int ReadScore(int income[], long num[]);
int LinSearch(long num[], long x, int n);
int main()
{
	int income[N], n, pos;
	long num[N], x;
	n = ReadScore(income, num);
	printf("Total number is %d\n", n);
	printf("Input the searching ID:");
	scanf("%d", &x);
	pos = LinSearch(num, x, n);
	if (pos != -1)
	{
		printf("income = %d\n", income[pos]);
	}
	else
        {
		printf("Not found!\n");
	}
	return 0;
}

int ReadScore(int income[], long num[])
{
	int i
	do{
		i++;
		printf("Input person's ID and income:");
		scanf("%d%d", num[i], income[i]);
	} while (num[i] >0 &&

你可能感兴趣的:(C语言苏小红改错题,c语言)