Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<fstream>
- using namespace std;
- typedef struct verseny{
- char id[6];
- char v[15];
- }verseny;
- int main()
- {
- char m[15];
- fstream f;
- int i=0;
- int db;
- verseny t[500];
- f.open("valaszok.txt",ios::in);
- f>>m; //megoldásai a versenynek
- while(!f.eof()){
- f>>t[i].id;
- f>>t[i].v;
- i++;
- }
- db=i-1;
- f.close();
- //cout<<t[db-1].id;
- cout<<"1.feladat"<<endl<<"2.feladat"<<endl<<db<<endl<<"3.feladat"<<endl<<" Versenyzo azonositoja:"<<endl;
- char ki[6];
- cin>>ki;
- int j;
- i=0;
- while(i<db){
- //if(ki==t[i].id) cout<<t[i].v<<" ezt valaszolta a versenyzo"<<endl;
- j=0;
- /*while(ki[j]==t[i].id){
- }*/
- while(ki[j]!='\0'){
- if(ki[j]==t[i].id[j]) j++;
- else {
- j=-1;
- break;
- }
- }
- if(j==-1) i++;
- else {
- cout<<"Ezt valaszolta a versenyzo: "<<t[i].v<<endl;
- break;
- }
- }//i-edik helyen van a megadott azonosito
- cout<<"4.feladat"<<endl;
- cout<<m<<endl;
- j=0;
- while(j<14){
- if(m[j]==t[j].v[j]) cout<<"+";
- else cout<<" ";
- j++;
- }
- cout<<endl;
- cout<<"5.feladat"<<endl;
- i=0;
- cout<<"adjon meg egy feladat sorszamat"<<endl;
- int sorsz;
- cin>>sorsz;
- int helyes=0;
- while(i<db){
- if(m[sorsz-1]==t[i].v[sorsz-1]) helyes++;
- i++;
- }
- cout<<" a feladatra "<<helyes<<" fo "<<(double)((int)helyes)/db*100<<"% pontossaggal adott helyes valaszt"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement