求解:数组的输入输出及查找功能的实现
#include<stdio.h>#include<stdlib.h>
#define N 100
//#include<stdio.h>
//#include<stdlib.h>
//#define N 100
void inputScore(int s[],int length);
void outputScore(int s[],int length);
int queryScore(int score[],int length,int xScore);
//void length=inputScore(score,N);
int main()
{
int length;
int score[N];
int xScore;
int i;
//int i;
//nt temp;
//i=length;
//length=inputScore(score,N);
inputScore(score,N);
outputScore(score,N);
//printf("以后%d",length);
/*if(i)
{
printf("你很棒!\n");
}
else
{
printf("滚球吧!\n");
}
}*/
//int score[N];
//int length;
// printf("");
printf("请输入要查找的成绩:");
scanf("%d",&xScore);
for(i=0;i<length;i++)
{
if(xScore==score[i])
{
return i;
printf("%d ",xScore);
}
}
return -1;
// system("pause");
system("pause");
}
void inputScore(int s[],int length)
{
int i,temp;
//int length;
int score[N];
for(i=0;i<length;)
{
printf("请输入%d个学生的成绩:",i+1);
scanf("%d",&temp);
if(temp==-1)
{
printf("输入结束!\n");
break;
}
else
{
score[i]=temp;
i++;
}
}
N=i;
// length=inputScore(score,N);
// return length;
//return temp;
//return length;
//return i;
//return N;
return i;
}
void outputScore(int s[],int length)
{
int i;
int score;
length=inputScore(score,N);
for(i=0;i<length;i++)
{
s[i]=i;
printf("%d\n",i+1);
//return i;
}
}
//#include<stdio.h>
//#include<stdlib.h>
//#define N 100
//void outputScore(int s[],int length);
//int main()
//{
//int score[N];
//int i;
// system("pause");
//}
//int queryScore(int score[],int length,int xScore);
//int main()
//{
//queryScore(score[],N,xScore);
//}
//int queryScore(int score[],int length,int xScore)
//{
功能实现:数据的输入输出 ,及数据的查找
麻烦各位老师 赐教,帮我看看是哪里出错了 谢谢