Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <locale.h>
  4. #include <windows.h>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int main (void)
  11. {
  12. setlocale(LC_ALL,"rus");
  13.  
  14. char buff[10]; char name[150]; char reg[10]; string bb; string rr; int fnd;
  15.  
  16. NEXT:
  17. ifstream fin("C:\\Users\\Андрюша\\Documents\\region.txt");
  18. if (!fin.is_open())
  19. cout << "Файл не найден!\n";
  20.  
  21. cout<<"Введите номер региона "; cin>>reg; rr=reg;
  22.  
  23. if (rr=="00") { cout<<"Выход из программы"<<endl;
  24. fin.close();
  25. return 0;}
  26.  
  27. while(!fin.eof())
  28. {
  29. fnd=0;
  30. fin >> buff; fin.getline(name,100,'\n'); bb= buff;
  31. if (bb==rr) { cout<<"Регион № "<< bb << " называется "<< name <<endl; fnd=1; break; }
  32. }
  33.  
  34. if (fnd==0) { cout<<"Регион не найден"<<endl; }
  35. else fnd=0;
  36.  
  37. strcpy(buff,""); strcpy(name,""); strcpy(reg,""); bb=""; rr="";
  38.  
  39. fin.close();
  40. goto NEXT;
  41.  
  42. system("pause");
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement