Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4. using namespace std;
  5.  
  6.  
  7. void Lettura( int vector[], int &i)
  8. {
  9. ifstream input;
  10. char nomefile[50];
  11. do
  12. {
  13. cout<<" inserisci il nome del file ";
  14. cin>> nomefile;
  15. cout<<endl;
  16. input.open(nomefile);
  17. if(!input.is_open())
  18. {
  19. cout<<"errore il nome del file non e' corretto"<<endl;
  20. }
  21. }while(!input.is_open());
  22.  
  23. i = 0;
  24. while(i<100 && !input.eof())
  25. {
  26. input>>vector[i];
  27. i++;
  28. }
  29. input.close();
  30. }
  31.  
  32. void stampa (int vector[],int i)
  33. {
  34. for(int j =0;j<i;j++)
  35. {
  36. cout<< vector[j] << " -";
  37. }
  38. }
  39.  
  40.  
  41. void bubblesort(int v[], int n) {
  42. int i,k;
  43. int temp;
  44. for(i = 0; i<n-1; i++) {
  45. for(k = 0; k<n-1-i; k++) {
  46. if(v[k] > v[k+1]) {
  47. temp = v[k];
  48. v[k] = v[k+1];
  49. v[k+1] = temp;
  50. }
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement