https://docs.google.com/document/d/1hl3DT6tvtfwqp60cVexvn__YjBzAnuxvzczapw2QUF8/edit
Programozási alapismeretek 2. - 10. hét
April 20, 2012 14:15
The site is loading…
https://docs.google.com/document/d/1g2RN0y2gm_-wsCdUFLFLFVf8ckdqLPndkZZXKboZ9YU/edit
binfa.h:
#ifndef BINFA_H_INCLUDED
#define BINFA_H_INCLUDED
#include <iostream>
typedef char TElem;
struct BinFaElem;
typedef BinFaElem* BinFa;
struct BinFaElem {
TElem ertek;
BinFa bal;
BinFa jobb;
};
void EgyElemuFa(BinFa &f, const TElem e);
#endif // BINFA_H_INCLUDED
binfa.cpp:
#include "binfa.h"
void EgyElemuFa(BinFa &f, const TElem e){
f = new BinFaElem;
//(*f).ertek = e; // ugyanaz mint az alatta levo
f->ertek = e;
f->bal = NULL;
f-> jobb = NULL;
}
main.cpp:
#include <iostream>
#include "binfa.h"
using namespace std;
int main(){
BinFa f = NULL, f2, f3;
EgyElemuFa(f, 'a');
EgyElemuFa(f2, 'b');
EgyElemuFa(f3, 'c');
f->bal = f2;
f->jobb = f3;
return 0;
}
https://docs.google.com/document/d/1uaCgD9nvjyhpG8gDEYpZYvFmetwnx6RACpfDHrTRVyg/edit
#include #include using namespace std; void beolvasas(vector &t); void feladat8(const vector t, int &db); bool volt(const int i, const vector t); int main(){ vector t; int db; beolvasas(t); feladat8(t, db); cout << db << " db kulonbozo tipus van!" << endl; return 0; } void beolvasas(vector &t){ int n; cout << "N="; cin >> n; t.resize(n); for(int i=0; i> t[i]; } } void feladat8(const vector t, int &db){ db=0; int n = t.size(); for(int i=0; it){ int j=0; while(j
#include #include #include using namespace std; void beolvasas(vector > &t); void fel5(const vector > t, int &hol); double osszeg(const int i, const vector > t); int main(){ vector > t; int hol; beolvasas(t); fel5(t, hol); cout << hol << ". a legnagyobb!" << endl; return 0; } void beolvasas(vector > &t){ int n; ifstream ifs("be.txt"); ifs >> n; t.resize(n); for(int i=0; i> t[i][j]; } } } void fel5(const vector > t, int &hol){ double max; int n = t.size(); hol = 0; max = osszeg(0, t);; for(int i=0; imax){ hol=i; max=osszeg(i, t); } } } double osszeg(const int i, const vector > t){ double s=0; for(int j=0;j