fork download
  1. #include <iostream>
  2. #include<string>
  3. using namespace std;
  4. int main()
  5. {
  6. int a[10],i,index;
  7. int *max;
  8. for(i=0;i<10;i++)
  9. cin>>a[i];
  10. max=a;
  11.  
  12. for(int* p=a;p<a+10;p++){
  13. if(*p>*max){
  14. max=p;
  15. }
  16. }
  17. cout<<"Highest value="<<*max<<endl<<"is at index="<<max - a<<endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 4224KB
stdin
2 3 4 1 0 10 9 3 8 7
stdout
Highest value=10
is at index=5