C language, the issue ordered (the number of inputs n, the maximum output)

int n,max=0,t;

scanf("%d",&n);

int a [n], i, k; // this a [n] need to be defined after the input value of n, not otherwise defined.

for(i=1;i<=n;i++)

a [i] = 0; // Application n values

for(k=1;k<=n;k++)

{ scanf("%d",&t);

  a[k]=t;

}

for(i=1;i<=n;i++)

{  if(max<a[i])

     max=a[i];

}

printf("%d",max);

Guess you like

Origin www.cnblogs.com/advsd/p/11724973.html