Produce output

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2007
Posts: 219
Reputation: nurulshidanoni is an unknown quantity at this point 
Solved Threads: 0
nurulshidanoni's Avatar
nurulshidanoni nurulshidanoni is offline Offline
Posting Whiz in Training

Produce output

 
0
  #1
May 5th, 2008
why the output do not produce the output after sorting....anybody knows how to do a selection sort code?


  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <cmath>
  5. #include <iomanip>
  6. #include <fstream>
  7. using namespace std;
  8.  
  9. void selectionSort(int *y,int n)//selection sort function
  10. {
  11. int i, min,minat ;
  12. {
  13. for(i=0;i<3;i++)
  14. {
  15. minat=i;
  16. min=y[i];
  17.  
  18. if(min<y[i])
  19. {
  20. minat=i;
  21. min=y[i];
  22. }
  23. }
  24. int temp=y[i] ;
  25. y[i]=y[minat]; //swap
  26. y[minat]=temp;
  27.  
  28. }
  29. }
  30.  
  31. int main()
  32. {
  33. int x, y;
  34. ifstream inFile("jes.txt");
  35.  
  36. for (int i = 0; i < 3; i++)
  37. {
  38. if (inFile >> x >> y)
  39. { // Reading is successful
  40. if (inFile.fail())
  41. {
  42. cout << "Error! Cannot open file! \n";
  43. return -1;
  44. }
  45. cout <<" "<< x <<" "<<y<< endl;
  46. }
  47. // Print out sorted list.
  48.  
  49. }
  50.  
  51. cout<<"After Descending Order"<<"\n";
  52.  
  53. cout << x <<" "<< y <<" " ;
  54. cout << endl;
  55.  
  56. return 0;
  57. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 343 | Replies: 0
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC