Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <conio.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <fstream>
  8. #include <time.h>
  9.  
  10. #define max_size 255
  11.  
  12. using namespace std;
  13.  
  14. int I, N = 0;
  15. int *main_massive;
  16.  
  17. char buf[max_size];
  18.  
  19. int *create_massive(int *main_massive );
  20.  
  21. int main()
  22. {
  23.  
  24.     ifstream file;
  25.     file.open("1.txt",ios::in);
  26.  
  27.     if (!file)
  28.     {
  29.         cout << "cannot open the file";
  30.         _getch();
  31.         return 1;
  32.  
  33.     }
  34.                
  35.     file.getline(buf,max_size);
  36.  
  37.     cout << buf<<"\n\n";
  38.    
  39.     main_massive = create_massive(main_massive);
  40.  
  41.     for(I = 0;I<N;I++)
  42.     cout << main_massive[I];
  43.    
  44.  
  45.     file.close();
  46.    
  47.     _getch();
  48.  
  49.     return 0;
  50.  
  51. }
  52.  
  53.  
  54. int *create_massive (int *main_massive)
  55. {
  56.  
  57.     int date_position = 0;
  58.  
  59.     for (I = 0;I < strlen(buf);I++)
  60.     if (isdigit(buf[I]))
  61.         N++;
  62.  
  63.     main_massive = new int[N];
  64.  
  65.    
  66.     for (I = 0;I < strlen(buf);I++)
  67.     if (isdigit(buf[I]))
  68.     {
  69.  
  70.         main_massive[date_position] = atoi (&buf[I]);
  71.         date_position++;
  72.  
  73.     }
  74.  
  75.     return main_massive;
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement