#include <fstream>
#include <vector>
#include <cmath>
using namespace std;
int dec_to_hex(int n) {
vector <int> reszty;
while (n > 0) {
int temp = n % 8;
reszty.push_back(temp);
n /= 8;
}
int x = 1;
int out = 0;
for (int i=reszty.size()-1; i >= 0; i--) {
out += reszty[i]*x;
x *= 10;
}
return out;
}
int hex_to_dec(int n) {
int out = 0;
int x = 0;
while (n > 0) {
int temp = n %10;
out += temp*pow(8, x);
x++;
n /= 10;
}
return out;
}
int licz_6(int n) {
int x = 0;
while (n > 0) {
if (n % 10 == 6) x++;
n /= 10;
}
return x;
}
int main() {
ifstream liczby1("liczby1.txt");
ifstream liczby2("liczby2.txt");
ofstream wyniki("wyniki.txt");
int hex, dec, old_dec, same = 0, hexb = 0, dec6 = 0, hex6 = 0;
int maxh = -1, minh = -1, ciag1 = -1, ciagd = 1, ciagdm = 0, ciag1m;
for (int i=0; i<1000;i++) {
liczby1 >> hex;
liczby2 >> dec;
if (hex > maxh || maxh == -1) maxh = hex;
if (hex < minh || minh == -1) minh = hex;
if (i == 0) ciag1 = dec;
else {
if (old_dec <= dec) {
ciagd++;
} else {
if (ciagdm < ciagd) {
ciag1m = ciag1;
ciagdm = ciagd;
}
ciag1 = dec;
ciagd = 1;
}
}
old_dec = dec;
if (hex_to_dec(hex) == dec) same++;
else if (hex_to_dec(hex) > dec) hexb++;
dec6 += licz_6(dec);
hex6 += licz_6(dec_to_hex(dec));
}
//jezeli ciag konczy sie razem z plikiem
if (ciagdm < ciagd) {
ciag1m = ciag1;
ciagdm = ciagd;
}
wyniki << "Podpunkt 1" << endl;
wyniki << "Max: " << maxh << endl << "Min: " << minh << endl;
wyniki << "Podpunkt 2" << endl;
wyniki << "Dl ciagu: " << ciagdm << ", 1szy element: " << ciag1m << endl;
wyniki << "Podpunkt 3" << endl;
wyniki << "Takie same: " << same << ", 1 > 2: " << hexb << endl;
wyniki << "Podpunkt 4" << endl;
wyniki << "6stki w dziesietnym: " << dec6 << endl;
wyniki << "6stki w osemkowym: " << hex6 << endl;
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}