SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. typedef struct valaszok{
  7.     char id[6];
  8.     char v[15];
  9.     int helyesek;
  10.  
  11. } valaszok;
  12.  
  13. int main()
  14. {
  15.     fstream f;
  16.     f.open("valaszok.txt",ios::in);
  17.     int i=0;
  18.     char m[15];
  19.     int db;
  20.     f>>m;
  21.     valaszok t[500];
  22.     while(!f.eof()){
  23.         f>>t[i].id;
  24.         f>>t[i].v;
  25.         i++;
  26.  
  27.  
  28.     }
  29.     db=i-1;
  30.     cout<<"2. Feladat"<<endl;
  31.     cout<<db<<endl;
  32.  
  33.     cout<<"3. Feladat"<<endl;
  34.     cout<<"adja meg az azonositot"<<endl;
  35.     char ki[6];
  36.     cin>>ki;
  37.     i=0;
  38.     int j=0;
  39.     while(i<db){
  40.         //if(ki==t[i].id) cout<<t[i].v<<endl;
  41.         j=0;
  42.         //while(ki[j]!==t[i].id[j])j++;
  43.          while(ki[j]!='\0'){
  44.             if(ki[j]==t[i].id[j]) j++;
  45.             else{
  46.                 j=-1;
  47.                break;
  48.             }
  49.          }
  50.         if(j==-1)i++;
  51.         else{ cout<<t[i].v<<endl;
  52.         break;}
  53.     }
  54.  
  55.  
  56.  
  57.     f.close();
  58.     return 0;
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top