练习指法
一般方法: #define n 10 main() { int a,i,max=0;
for(i=0;i<n;i++){ printf("\nPlease input the %dth number :",i+1); scanf("%d",&a); if(max<a) max=a; }
printf("The Max number is: %d",max); getch(); }
指针法 #define n 10 main() { int s[n],*p,i,max=0;
p=s; for(i=0;i<n;i++,p++){ printf("\nPlease input the %dth number: ",i+1); scanf("%d",p); if(max<*p) max=*p; }
printf("\nThe Max number is %d",max); getch(); }
数组法 #define n 10 main() { int s[n],i,max=0;
for(i=0;i<n;i++){ printf("\nPlease input the %dth number: ",i+1); scanf("%d",&s[i]); if(max<s[i]) max=s[i]; }
printf("\nThe Max number is %d",max); getch(); }