tags:

views:

63

answers:

2

for example there is code

#include <algorithm>
#include <stdio.h>
#include <iostream>



int intcomp(int *x,int *y) {  return *x-*y;};
int a[10000];
int main(void){
    int i; int n=0;
     while (scanf("%d",&a[n])!=EOF)
          n++;
     qsort(a,n,sizeof(int),intcomp);
      for (int i=0;i<n;i++)
           printf("%d\n",a[i]);
       return 0;


}

how tell computer that EOF is reached?

+6  A: 

You mean when entering input interactively? In a windows shell, ctrl+z on a line on its own. In a *nix shell, ctrl+d. Or just put your input in a file and pipe it, then not only will eof be detected at the appropriate time but also you can automate your testing.

moonshadow
+1  A: 

You should use CTRL+Z combination (or somehow input character with code 26, for example, by pressing ALT+2+6 on additional keyboard)

UnknownGosu