Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * lab5v9.cxx
- *
- * Copyright 2018 Денис <altracer@AspireE15>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- *
- */
- #include <iostream>
- #include <math.h>
- #include <locale.h>
- using namespace std;
- int main(int argc, char **argv)
- {
- //setlocale(LC_ALL,"ru_RU.ISO-8859-5");
- short l = 3;
- char a[l+1]; // last symbol is line terminator '\0'
- char b[l+1];
- float e;
- short i,j,c,d;
- cout << "Введите два числа: в восьмеричной от 000 до 777" << endl;
- cout << "и в четверичной, от 000 до 333:" << endl;
- cin >> a;
- cin >> b;
- const char oct_alphabet[9] = "01234567";
- const char four_alphabet[5] = "0123";
- int dec_alphabet[8];
- for(i=0;i<=7;i++) dec_alphabet[i]=i;
- for(i=0;i<=l-1;i++){
- for(j=0;j<=7;j++){
- if(a[l-1-i]==oct_alphabet[j]) c+=dec_alphabet[j]*pow(8,i);
- };
- };
- for(i=0;i<=l-1;i++){
- for(j=0;j<=3;j++){
- if(b[l-1-i]==four_alphabet[j]) d+=dec_alphabet[j]*pow(4,i);
- };
- };
- e=c/d;
- cout << c <<endl;
- cout << d <<endl;
- cout << e <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement