-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialog5.cpp
99 lines (85 loc) · 2.2 KB
/
dialog5.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "dialog5.h"
#include "ui_dialog5.h"
#include <QLabel>
//#include <QMessageBox>
Dialog5::Dialog5(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog5)
{
ui->setupUi(this);
}
Dialog5::~Dialog5()
{
delete ui;
}
void Dialog5::on_Dialog5_accepted(QString c,QString d,QString e,QString f,QString g,QString h,double a1,double b1,double c1,double d1,double e1,double f1)
{
double a[5];
a[0]=a1;
int k=0;
//QMessageBox::information(this,"t",QString::number(a[0]));
a[1]=b1;
a[2]=c1;
a[3]=d1;
a[4]=e1;
a[5]=f1;
QString b[5];
b[0]=c;
b[1]=d;
b[2]=e;
b[3]=f;
b[4]=g;
b[5]=h;
int x=30;
int i,j;
double temp;
// QString temp1;
for(i=0;i<6;i++)
{
for(j=i+1;j<6;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
QString tempa=b[i];
b[i]=b[j];
b[j]=tempa;
}
}
}
for(i=0;i<6;i++)
{
for(j=5;j>i;j--)
{
if(((-a[i])>a[j])&&a[i]!=0&&a[j]!=0)
{
a[i]=a[i]+a[j];
a[j]=0;
//label[k]= new QLabel(this);
//label[k]->setGeometry(290,x, 271, 20);
//label[k]->show();
// label[k]->setText(b[i]+" has to give "+QString::number(a[j])+" rupees to "+b[j]+".");
// ui->textBrowser->setText(b[i]+" has to give "+QString::number(a[j])+" rupees to "+b[j]+".");
k++;
x=x+30;
}
else if(((-a[i])<=a[j])&&a[i]!=0&&a[j]!=0)
{
a[j]=a[i]+a[j];
a[i]=0;
// label[k]= new QLabel(this);
// label[k]->setGeometry(290,x, 271, 20);
//label[k]->show();
//label[k]->setText(b[i]+" has to give "+QString::number(-a[i])+" rupees to "+b[j]+".");
k++;
x=x+30;
}
else
{
x=x+0;
}
}
}
}