Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring> // strcmp( char t, char t2)
- #include <iomanip> //setprecisionhoz ha akarod
- typedef struct verseny{
- char id[6]; //string
- char v[15];
- }verseny;
- using namespace std;
- int main()
- { char M[15];
- verseny t[500];
- int i=0;
- int db;
- cout<<"1. feladat: Az adatok beolvasasa"<<endl;
- fstream f;
- f.open("valaszok.txt",ios::in);
- f>>M;//megoldokulcs
- while( !f.eof() ){
- f>>t[i].id;
- f>>t[i].v;
- i++;
- }
- db=i-1;
- f.close();
- //cout<<t[db-1].v<<endl;
- cout<<"2. feladat: "<<db<<endl;
- cout<<"2. feladat: Versenyzo azon: "<<endl;
- char ki[6];
- //cout<<t[0].id;
- cin>>ki;
- int j;
- i=0;
- while(i<db){
- if(strcmp(ki,t[i].id)==0) cout<<t[i].v<<" ezt valasszolta a kotsog"<<endl;
- j=0;
- //while(ki[j]==t[i].id[j])j++;
- while(ki[j]!='\0'){
- if(ki[j]==t[i].id[j]) j++;
- else {
- j=-1;
- break;
- }
- }
- if(j==-1) i++;
- else {
- cout<< t[i].v<<endl;
- break;
- }
- }
- //i-edik helyen van a illeto megoldása
- //compare???
- cout<<"4. feladat:"<<endl;
- cout<<M<<endl;
- j=0;
- while(j<14){
- if(M[j]== t[i].v[j]) cout<<"f";
- else cout<<" ";
- j++;
- }
- cout<<"5. feladat: A feladat sorszama ="<<endl;
- int sorsz;
- cin>>sorsz;
- i=0;
- int helyes=0;
- while(i<db){
- if(M[sorsz-1]== t[i].v[sorsz-1]) helyes++;
- i++;
- }
- cout<<"A feladatra "<<helyes<<" fo ..."<< (double)100*helyes/db <<" % adott"<<endl;
- cout<<setprecision(4)<<(double)100*helyes/db<<" % adott"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement