Example #1
0
void main()
{
 int key[20];
 int id[50];
 int scores[50];
 int ans[20];
 float avg;
 int nq,ns,oid;
 clrscr();
 ns = 0;
 /*input number of questions on test*/
 scanf("%d",&nq);
 /*input answer key*/
 inputarray(key,nq);
 while(scanf("%d",&oid) != EOF)
  {
	/*input individual students scores*/
	inputarray(ans,nq);
	/*store id number aquired earlier in scanf in id[]*/
	id[ns] = oid;
	/*score individual students test*/
	scores[ns] = scoretest(key,ans,nq);
	ns++;

  }
 /*calculate average score for entire class*/
 avg = average(scores,ns);
 /*sort class scores in descending order*/
 sortscores(scores,id,ns);
 /*output results to screen*/
 printresults(id,scores,avg,ns);
}
Example #2
0
int main(void)
{
	int N,*p;
	int i;
	printf("please input N:\n");
	scanf("%d",&N);
	p=malloc(N*sizeof(int));
	inputarray(p,N);
	sort(p,N);
	printarray(p,N);	
}