it work in devC++, but application don't work

Hello there, I'm new with C++, I have a program in C++ that runs fine in devC++ using compile&run feature, but when I click to that application, it works not right.
When I hit number 1 or 2 or 3, then enter, it should do some calculation and print out something. But in application, after 1 or 2 and enter, it exits.
Can someone check it out for me, I have tested this in another computer and another c++ software, same issue.

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
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <math.h>
using namespace std;
float random( float min, float max )
{
    float scale = rand() / ((double) RAND_MAX); 
    return min + scale * ( max - min );      
}
int main()
{
			srand((int) time(NULL));
	int m,n,k,z;
	float lamda;
	do
	{
	cout<<"Chuong trinh mo phong he thong truyen tin"<<endl;
	cout<<"Vui long chon bo tham so"<<endl;
	cout<<"1. n=7; m=4; k=3; lamda=0.00002"<<endl;
	cout<<"2. n=10; m=7; k=3; lamda=0.00001"<<endl;
	cout<<"3. tuy chon"<<endl;
		int z =1;
	cin>>z;
	if(z==1){
		n=7,m =4,k =3;
		lamda = 0.00002;}
	else if(z==2){ 	
		n=10,m =7,k =3;
		lamda = 0.00001;}
	else if(z==3){
	cout<<"nhap gia tri n:  ";
	cin>>n;
	cout<<"nhap gia tri m :  ";
	cin>>m;
	cout<<"nhap gia tri k:  ";
	cin>>k;
	cout<<"nhap gia tri lamda:  ";
		cin>>lamda;
	}}
while(m<=0 or n<=0 or k<=0 or lamda<=0);
	int Q0=0,Q1=0;
	int S=3000;
	for(int i=0;i<S;i++)
	{
		double X = random(0,1);
		double Y= -log(X);
		int T= Y/lamda;
		int PN= T/n;					
		if(T>=n){
			Q0=Q0+ PN;
			double PL=T-PN*n; 			
			if(PL>0){
				Q1=Q1+1;
			}
		} 
		else {
			Q1=Q1+1;
		}
	}
	float PS=double(Q0)/(double(Q0+Q1));
	float PD=1-PS;
	float V=m*(1-PS)/n;
	cout<<"so lan truyen tin sai Q1 = "<<Q1<<endl;
	cout<<"so lan truyen tin sai Q0 = "<<Q0<<endl;
	cout<<"3. tuy chon";
	cout<<"voi cuog do hong hoc lamda = "<<lamda<<"l/h"<<" va chieu dai tu ma la "<<n<<"("<<m<<","<<k<<")"<<endl;
	cout<<"Xac suat sai la Ps:"<<PS<<endl;
	cout<<"Xac suat dung la Pd:"<<PD<<endl;
	cout<<"Toc do truyen tin la V:"<<V<<endl;
	
}

Thanks for reading all of this
Runs OK without crashing using XCode and cppshell. Of course the Vietnamese, without being translated, means zip to me.

Chuong trinh mo phong he thong truyen tin
Vui long chon bo tham so
1. n=7; m=4; k=3; lamda=0.00002
2. n=10; m=7; k=3; lamda=0.00001
3. tuy chon
3
nhap gia tri n:  1
nhap gia tri m :  2
nhap gia tri k:  4
nhap gia tri lamda:  33
so lan truyen tin sai Q1 = 3000
so lan truyen tin sai Q0 = 0
3. tuy chonvoi cuog do hong hoc lamda = 33l/h va chieu dai tu ma la 1(2,4)
Xac suat sai la Ps:0
Xac suat dung la Pd:1
Toc do truyen tin la V:2

after 1 or 2 and enter, it exits.


I think you mean ... after 1 or 2 and enter, it does its calculations, finishes and exits (i.e., closes the command window).

Stop it finishing (e.g. by asking for user input).

You might want to read
http://www.cplusplus.com/forum/beginner/1988/#msg7262
Last edited on
Dừng hoàn thiện (ví dụ: bằng cách yêu cầu người dùng nhập liệu).

Bạn có thể muốn đọc
http://www.cplusplus.com/forum/beginner/1988/#msg7262
Topic archived. No new replies allowed.