Commit 8c1a1db2 authored by Ingemar Ceicer's avatar Ingemar Ceicer

Windows 64, Windows console

parent ac510834
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="sv_SE">
<context>
<name>MainWindow</name>
<message>
<location filename="mainwindow.ui" line="14"/>
<source>MainWindow</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="75"/>
<location filename="mainwindow.ui" line="164"/>
<source>Add</source>
<translation>Lägg till</translation>
</message>
<message>
<location filename="mainwindow.ui" line="82"/>
<location filename="mainwindow.ui" line="169"/>
<location filename="mainwindow.cpp" line="47"/>
<source>LCD</source>
<translation>MGN</translation>
</message>
<message>
<location filename="mainwindow.ui" line="89"/>
<location filename="mainwindow.ui" line="179"/>
<source>Clear</source>
<translation>Rensa</translation>
</message>
<message>
<location filename="mainwindow.ui" line="144"/>
<source>File</source>
<translation>Arkiv</translation>
</message>
<message>
<location filename="mainwindow.ui" line="153"/>
<source>Language</source>
<translation>Språk</translation>
</message>
<message>
<location filename="mainwindow.ui" line="174"/>
<source>Exit</source>
<translation>Avsluta</translation>
</message>
<message>
<location filename="mainwindow.ui" line="188"/>
<source>English</source>
<translation>Engelska</translation>
</message>
<message>
<location filename="mainwindow.ui" line="197"/>
<source>Swedish</source>
<translation>Svenska</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="48"/>
<source>Copyright (C) 2018 Ingemar Ceicer. This is free software; see the GNU General Public Licence for copying conditions. There is NO warranty.
Least Common Denominator (LCD)</source>
<translation>Upphovsrätt (C) 2018 Ingemar Ceicer. Detta är fri programvara; se GNU General Public License för kopieringsvillkor. Det finns ingen garanti.
Minsta Gemensamma Nämnare (MGN)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="118"/>
<source>LCD = </source>
<translation>MGN = </translation>
</message>
<message>
<location filename="mainwindow.cpp" line="129"/>
<location filename="mainwindow.cpp" line="150"/>
<location filename="mainwindow.cpp" line="152"/>
<location filename="mainwindow.cpp" line="158"/>
<location filename="mainwindow.cpp" line="160"/>
<source>Sum = </source>
<translation>Summa = </translation>
</message>
<message>
<location filename="translate.cpp" line="14"/>
<location filename="translate.cpp" line="39"/>
<source>The program must be restarted for the new language settings to take effect.</source>
<translation>Programet måste startas om för att de nya språkinställningarna skall gälla.</translation>
</message>
<message>
<location filename="translate.cpp" line="15"/>
<location filename="translate.cpp" line="40"/>
<source>Restart Now</source>
<translation>Starta om nu</translation>
</message>
<message>
<location filename="translate.cpp" line="16"/>
<location filename="translate.cpp" line="41"/>
<source>Cancel</source>
<translation>Avbryt</translation>
</message>
</context>
</TS>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>MainWindow</name>
<message>
<location filename="mainwindow.ui" line="14"/>
<source>MainWindow</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="75"/>
<location filename="mainwindow.ui" line="164"/>
<source>Add</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="82"/>
<location filename="mainwindow.ui" line="169"/>
<location filename="mainwindow.cpp" line="47"/>
<source>LCD</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="89"/>
<location filename="mainwindow.ui" line="179"/>
<source>Clear</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="144"/>
<source>File</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="153"/>
<source>Language</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="174"/>
<source>Exit</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="188"/>
<source>English</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.ui" line="197"/>
<source>Swedish</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="48"/>
<source>Copyright (C) 2018 Ingemar Ceicer. This is free software; see the GNU General Public Licence for copying conditions. There is NO warranty.
Least Common Denominator (LCD)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="118"/>
<source>LCD = </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="129"/>
<location filename="mainwindow.cpp" line="150"/>
<location filename="mainwindow.cpp" line="152"/>
<location filename="mainwindow.cpp" line="158"/>
<location filename="mainwindow.cpp" line="160"/>
<source>Sum = </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="translate.cpp" line="14"/>
<location filename="translate.cpp" line="39"/>
<source>The program must be restarted for the new language settings to take effect.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="translate.cpp" line="15"/>
<location filename="translate.cpp" line="40"/>
<source>Restart Now</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="translate.cpp" line="16"/>
<location filename="translate.cpp" line="41"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
lcd.exe
lcdqtconsole.zip
lista.txt
Qt5Core.dll
vc_redist.x64.exe
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
/* ><(((*> ><(((*> ><(((*> ><(((*> ><(((*> ><(((*> ><(((*> ><(((*>
LCD Copyright 2018 Ingemar Ceicer
http://ceicer.org
programmeing1@ceicer.org
LCD 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 3 of the License, or
(at your option) any later version.
Foobar 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
><(((*> ><(((*> ><(((*> ><(((*> ><(((*> ><(((*> ><(((*> ><(((*> */
#include <QCoreApplication>
#include <iostream>
using namespace std;
void lcd(int[], int[], int);
void shortenFractionalNumbers(int numerator, int denominator);
#define MAX_FACTOR 1000000
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
cout << "Copyright (C) 2018 Ingemar Ceicer.\n";
cout << "This is free software; see the GNU General Public Licence\n";
cout << "for copying conditions. There is NO warranty.\n";
cout << "Least Common Denominator (LCD)\n";
cout << "Enter the number of fractional numbers :>";
int counter = 0, i = 0, number, numerator, denominator;
cin >> number;
if(number < 1)
return 0;
int *numeratorArray = new int[number];
int *denominatorArray = new int[number];
while(counter < number) {
cout << "Fraction " << ++counter << ": numerator :>";
cin >> numerator;
numeratorArray[i] = numerator;
cout << "Fraction " << counter << ": denominator :>";
cin >> denominator;
denominatorArray[i] = denominator;
i++;
}
cout << endl;
lcd(numeratorArray, denominatorArray, counter);
delete[] numeratorArray;
delete[] denominatorArray;
cout << endl;
system("pause");
return 0;
//return a.exec();
}
void lcd(int numeratorArray[], int denominatorArray[], int counter)
{
// Find the fractional number with the largest denominator
int factor, highest = 0, found, lcd, summa;
int *numerator = new int[counter];
// Practical test
// double a1, b1, a2, b2;
for(int i = 0; i < counter; i++) {
if(denominatorArray[i] > highest) {
highest = denominatorArray[i];
}
}
for(factor = 1; factor < MAX_FACTOR; factor++) {
found = 0;
for(int i = 0; i < counter; i++) {
if((((highest * factor) % denominatorArray[i]) == 0)) {
lcd = highest * factor;
numerator[i] = numeratorArray[i] * (lcd / denominatorArray[i]);
found++;
} else
break;
}
// If the LCD is found
if(found == counter) {
summa = 0;
for(int i = 0; i < counter; i++) {
summa += numerator[i];
cout << numeratorArray[i] << '/' << denominatorArray[i] << " = " << numerator[i] << '/' << lcd << endl;
// Practical test
/*
a1=(double)numeratorArray[i];
b1=(double)denominatorArray[i];
a2=(double)numerator[i];
b2=(double)lcd;
cout << a1/b1 << '=' << a2/b2 << endl;
*/
}
cout << "LCD = " << lcd << endl;
shortenFractionalNumbers(summa, lcd);
delete[] numerator;
return;
}
}
}
void shortenFractionalNumbers(int numerator, int denominator)
{
if((numerator % denominator) == 0) {
cout << "Sum = " << numerator / denominator;
return;
}
const int hogst = numerator > denominator ? numerator : denominator;
int num = 0, den = 0, heltal = 0, del = 0;
for(int i = 2; i < hogst; i++) {
if(((numerator % i) == 0) && (((denominator % i) == 0))) {
num = numerator / i;
den = denominator / i;
}
}
if(num == 0 && den == 0) {
heltal = numerator / denominator;
del = numerator % denominator;
if(heltal > 0)
cout << "Sum = " << numerator << '/' << denominator << " = " << heltal << ' ' << del << '/' << denominator << endl;
else
cout << "Sum = " << numerator << '/' << denominator << endl;
} else {
heltal = num / den;
del = num % den;
if(heltal > 0)
cout << "Sum = " << numerator << '/' << denominator << " = " << num << '/' << den << " = " << heltal << ' ' << del << '/' << den << endl;
else
cout << "Sum = " << numerator << '/' << denominator << " = " << num << '/' << den << endl;
}
}
MinGW
C:\Qt\Qt5.11.2\5.11.2\mingw53_32\bin\windeployqt.exe
MSVC++
C:\Qt\Qt5.11.2\5.11.2\msvc2017_64\bin\windeployqt.exe
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment