fatalaa

2002Acsop3

Nov 24th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main( int argc , char** argv )
  4. {
  5. int n = 1;
  6. int i;
  7. double tomb[ n ];
  8.  
  9. int min = 0 , max = 0;
  10. scanf( "%d" , &n );
  11.  
  12. for( i = 0; i < n; i++)
  13. {
  14. scanf( "%lf" , &tomb[ i ] );
  15. }
  16. //Minimumkeresés
  17. for( i = 0; i < n; i++ )
  18. {
  19. if( tomb[ i ] < tomb[ min ] )
  20. {
  21. min = i;
  22. }
  23. }
  24. printf( "A legkisebb elem: %lf\n" , tomb[ min ] );
  25. //Maximumkeresés
  26. for( i = 0; i < n; i++ )
  27. {
  28. if( tomb[ i ] > tomb[ max ] )
  29. {
  30. max = i;
  31. }
  32. }
  33. printf( "A legnagyobb elem: %lf\n" , tomb[ max ] );
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment