မဂၤလာပါခင္ဗ်ာ


ဧည့္သည္ေတာ္မ်ားကိုယ္စိတ္ႏွစ္ျဖာက်မ္းမာရႊင္လန္းၾကပါေစခင္ဗ်ာ။

c++ in lab




Exercise-1
Using the switch statement to write a program that implements a simple calculator action. Exit the program implemented through dialogue calculate every five values, such as «Exit from program (Y / N)?».






ဒီပရုိ ဂရမ္ေလးကေတာ့ ရုိးရုိး calculator ပရုိဂရမ္ ေလးပါ။ (+,-,*,/,^) ေပါင္း ႏႈတ္ ေျမွာက္ စား ထပ္ညႊန္းကိန္း တင္ လကၡ ေလးေတြကုိ switch ကေန ဖမ္းယူလုိက္တာပါ။အဲဒီ switch ကိုမွ အၾကိမ္ငါးၾကိမ္ အလုပ္လုပ္
လုပ္ဖို ့အတြက္ for loop နဲ ့ငါးၾကိမ္ပတ္ေပးျခင္းျဖစ္ပါတယ္။အဲဒီငါးၾကိမ္ျပီးတာနဲ ့Exist from program(Y/N)?
ေမးပါလိမ့္မယ္ ။ N လို ့type လိုက္မယ္ဆိုရင္ေတာ့ ပရုိဂရမ္ဟာ ေနာက္ငါးၾကိမ္အလုပ္လုပ္မွာျဖစ္ပါတယ္။
မဟုတ္ရင္ေတာ့ ပရုိမရမ္ end သြားပါျပီ။ Defaulf ကေတာ့ switch ရဲ ့ေအာက္မွထည့္သြင္းမထားတဲ့ အျခား သခ်ၤာ လကၡ ဏာေတြ ့ထည့္ရင္ Synatx Error သေဘာမ်ိဳးေလးေပါ့ ။မျဖစ္မေန လုပ္အပ္တဲ့အခ်က္ေတာ့မဟုတ္ပါဘူး။break က ေတာ့ဒီေန ရာမျဖစ္မေနလို အပ္ပါတယ္။မဟုတ္ရင္ေတာ့ ရုိက္လိုက္တဲ့ဂဏန္းေတြဟာရပ္မသြားပဲ
(+,-,*,/,^) ထဲက ရုိက္တဲ့ လကၡရဲ ့ေအာက္က operations ေတြပါဆက္ျပီးေတာ့ လုပ္လုပ္သြားပါလိမ့္မယ္။ အဲဒါေၾကာင့္ break ထည့္ဖို ့ေတာ့မေမ့ ဖုိ ့လုိတာေပါ့ေနာ္။
ပံုက မရွင္းဘူးျဖစ္ေနတယ္ ။ပံုမွာသာ click ၾကည့္လုိက္ပါ အဆင္ေျပသြားပါလိမ့္မယ္။



C++ အေျခခံမ်ား

ကဲလာပါျပီ ....စာေမးပြဲ ကဒီေန့မွ နုွတ္ေျဖျပီးလို ့ဗ်ိဳ့။တစ္ခုနဲ့ တစ္ခုၾကားlinkingေတာ္ေတာ္ျပတ္သြားလို့ ေတာင္း ပန္ပါတယ္ဗ်ာ။စာေမးပြဲနဲ့ မအားလို့ပါ။ဆက္ေရးပါ့မယ္။အရင္တစ္ေခါက္တုန္းက conio.hမွာျပီးသြားတာ။ ဆက္ ေရးမယ္ေနာက္ထပ္က်န္တာေလးေတြေပါ့။ကဲစမယ္...................

5.Standar Library Header File(stdlib.h)
1)abs(int var)-အင္တီဂ်ာေခၚကိန္းျပည့္ တန္ဖိုးတိတိက်က်ရဖို့အတြက္။
2)atof(const char*s)-အကၡရာကေန floating pointလုိ့ေခၚတဲ့ ဒႆမကိန္းေျပာင္းဖို့အတြက္။
3)atoi(const char*s)-အကၡရာကေန intergerလုိ့ေခၚတဲ့ ကိန္းျပည့္ေျပာင္းဖို့အတြက္။
4)atol(const char*s)-အကၡရာကေန long integerလုိ့ေခၚတဲ့တန္ဖိုးၾကီးလြန္းေသာကိန္းျပည့္ေျပာင္းဖို့အတြက္။
5)div(int,int)-ကိန္းျပည့္နွစ္ခုစားျပီးေနာက္ စားလဒ္နဲ့ အၾကြင္းတန္ဖိုးေတြကို ျပဖို့အတြက္ပါ။
ဥပမာ ဗ်ာ(x=div(15,4); x.quot=3 (စားလဒ္) x.rem=3(အၾကြင္း))ေပါ့။
6)ltoa(long int)-ဒါကေတာ့ atolရဲ့ေျပာင္းျပန္ long integerလုိ့ေခၚတဲ့တန္ဖိုးၾကီးလြန္းေသာကိန္းျပည့္ က ေန အကၡရာကိုေျပာင္းဖို့အတြက္။
7)itoa(int)-ဒါေလးက်ေတာ့ atoiရဲ့ေျပာင္းျပန္ကိန္းျပည့္ကေနအကၡရာကိုေျပာင္းဖို့အတြက္။
8)rand( )%int-ဒါေလးက randomကိန္းသံုးဖို့ ။
ဥပမာဗ်ာ ၁ကေန ၅၀အတြင္းကိန္းေတြကို ကုိယ္က ကီးဘုတ္ကေနရိုက္ထည့္စရာမလိုပဲ programက ေအာ္ တိုသံုးသြားေအာင္သံုးရတာ ...ဒါဆိုရင္ဒီလိုေလးေရးလိုက္ေပါ့ a[i]=rand( )%50။

6.Character Type Header File(ctype.h)
1)toupper(int char)-ဒါေလးက အကၡရာကို အကၡရာအၾကီး ေျပာင္းဖို့ေပါ့။ဥပမာ a,b,cကေနA,B,C ဆိုျပီးေျပာင္းတာ။
2)tolower(int char)-ဒါေလးက အကၡရာကို အေသး ေျပာင္းဖို့ေပါ့။ဥပမာA,B,Cကေန a,b,cဆိုျပီးေျပာင္းတာ။
3)toascii(int char)-ဒါကေတာ့အကၡရာကို ASCII ကုဒ္ကို ေျပာင္းဖို့ပါ။အရွည္ကေတာ့ American Stardar Code for Information Interchange ပါ။ASCII codeကို အေသးစိတ္ေလ့လာခ်င္တယ္ ဆိုရင္ေတာ့ http://en.wikipedia.org/wiki/ASCII

7.Mathematical Header File(math.h)
1)sin(value)
2)cos(value)
3)tan(value)
4)sqrt(value)-square root တြက္ဖို့ပါ။
5)log(value)-natural logarithm တြက္ဖို့ပါ။(သခ်ၤာမွာဆို ln လုိ့ေရးတာေပါ့ဗ်ာ...)
6)exp(value)-exponential functionတြက္ဖို ့ပါတဲ့။(သခ်ာၤမွာဆိုရင္ e to the power x ေပါ့)
7)pow(base,exp)-ဒါက ကိန္းေတြကို ထပ္ညႊန္းတင္ဖို့သံုးတာ။ရွင္းပါတယ္။ 10 to the power 5 ဆိုရင္ 10က base ၊5က expေပါ့။
8)ceil(x)-xထက္ငယ္တဲ့ အငယ္ဆံုးကိန္းျပည့္ကို ရွာဖို့ပါ။ဥပမာ x=3ဆိုရင္ 3ထက္ငယ္တဲ့ ကိန္းကိုရွာေပးမွာပါ။ ကဲဒါေတြကေတာ့ C++မွာ က်ြန္ေတာ္သိသမွ် Header Fileအကုန္ပါပဲ။အမွားပါရင္လည္း commentေပးျပီး ကူညီက်ပါအံုး။စာရိုက္တာ အမွားပါမွာဆိုးလုိ့ပါ။ျပီးေတာ့ က်ြန္ေတာ္လည္း အခုမွစေလ့လာသူပါ။က်ြန္ေတာ္ သိတာေလးကို လံုးဝမသိတဲ့ စတင္ေလ့လာသူေတြကို ျပန္ေျပာျပတဲ့သေဘာပါ။ အခုလို့ ေလ့လာသြားတဲ့ အတြက္လည္း ေက်းဇူးတင္ပါတယ္ဗ်ာ။ေနာက္လည္းဆက္ေရးသြားပါအံုးမယ္။

လက္ေဆာင္ရတဲ့ ေကာင္မေလး

ဒီေကာင္မေလးကေတာ့ 9Dragons ကေန ကၽြန္ေတာ့္ကို လက္ေဆာင္ေပးတဲ့ေကာင္မေလးပါ။ အျမဲတမ္းေတာ့မဟုတ္ဘူးခင္ဗ်။ တစ္လေပးေဆာ့တာပါ။
ဒီလယ္ဗယ္ကေတာ့ ဂိမ္းအေစာင့္ေတြမွာသာထားရွိတဲ့ လယ္ဗယ္ပါ။ လယ္ဗယ္ ၂၀၀ ျဖစ္ပါတယ္။ 9Dragons ရဲ႕ ၆ ႏွစ္ခန္႔သက္တမ္းအတြင္းမွာ လယ္ဗယ္အျမင့္ဆံုးက ၁၈၁ သာရွိပါေသးတယ္။
လြန္ခဲ့တဲ့လက တစ္လအတြင္း လယ္ဗယ္အျမင့္ဆံုးသံုးေယာက္ကို ဆုေပးတာျဖစ္ပါတယ္။ သူမ်ားေတြကေတာ့ ဘယ္လို ဆုရတယ္ မသိပါဘူး။ ကၽြန္ေတာ္ကေတာ့ ေငြတစ္ျပားမွ မကုန္ပဲ နာမည္ေလးသစ္ေလးနဲ႔ ဒီေကာင္မေလးကို ရတာပါပဲ။ ျမန္မာအခ်င္းခ်င္းေခၚၾကတဲ့နာမည္ကေတာ့ ThuKhoeGyi (သူခိုးၾကီး) တဲ့ဗ်ာ။
စိတ္ပါ၀င္စားသူ ညီကိုေမာင္ႏွမမ်ား ဆက္သြယ္ႏုိင္ပါေၾကာင္းခင္ဗ်ား။


C++ အေျခခံမ်ား

စစခ်င္းဘာေရးရမွန္းမသိေသးလို ့ C++ေရးရင္ေၾကျငာရတဲ့ Header Filesေတြအေၾကာင္း ေျပာျပခ်င္ပါတယ္။ သိျပီးသားဆိုရင္လည္း ေက်ာ္ဖတ္သြားၾကပါ။မသိေသးတဲ့ သူေတြအတြက္ပါခင္ဗ်ာ။
Standard Header File & Their Functions

1.Basic Input & Output Header File(iostream.h)
သူ ့ကိုေတာ့ cout နွင့္ cin commands ေတြကို ထည့္သံုးမွာမို့လို့ ေၾကျငာရတာပါ။

2.Standard Input &Output Header File(stdio.h)
သူ ့ကိုေတာ့ printf ႏွင့္ scanf commands ေတြကို သံုးဖို ့ေၾကျငာတာပါ။(cin & cout အစားသူတို့ကိုသံုးတာပါ။ ပံုစံေတာ့ နည္းနည္းကြဲတာေပါ့။
ဥပမာ
cout<<"My name is"; cin>>name;အစား
printf("My name is");
scanf("name");ဆိုျပီး ေရးရတာပါ။ပံုစံေလးပဲကြဲတာပါ။ဆိုလိုရင္းကေတာ့ အတူတူပါပဲ။

3.Formatting iostream output(iomaip.h)
သူ ့ကိုေတာ့ ဒသမကိန္းကိုလိုခ်င္သေလာက္ျဖတ္ဖို့နဲ့ ကိန္းတစ္ခုနဲ ့တစ္ခုၾကား space ျခားဖို့သံုးတာပါ။
1)setprecision(2)လို ့သံုးလိုက္ရင္ အရင္က ရွိတာက x=123.4567ဆိုပါေတာ့။အဲ့ဒါကိုသံုးလိုက္တဲ အတြက္ ဒသမကိန္းေနာက္က ကိန္း၂လံုးကိုပဲျပပါေတာ့မယ္။ ဒီမွာၾကည့္မွာ x=123.45 ဆိုျပီး ျဖစ္သြားပါတယ္။
2)setw(5)လို့ သံုးရင္ေတာ့ ထြက္လာတဲ့ အေျဖေတြကို တစ္ခုနဲ့တစ္ခု space (၅)ေနရာစာျခားျခားသြားျပီး ျပ သြားမွာပါ။"\t"လည္း ဒီလိုပါပဲ။ဒါေပမဲ့ ဒီေကာင္ကေတာ့ တစ္ခ်က္စာပဲျခားမွာပါ။setw(-)ကေတာ့ ကိုယ္သတ္ မွတ္ခ်င္သေလာက္သတ္မွတ္ျပီး ျခားနိုင္တာေပါ့ဗ်ာ။

4.Console Input & Output Header File(conio.h)
1)clreol()-သူက လိုင္းတစ္လိုင္းကိုပဲ အဆံုးအထိ ရွင္းလင္းဖို့သံုးတာပါ။
2)clrscr()-သူကေတာ့ အရင္အေျဖထုတ္တုန္းက screenမွာေပၚေနတဲ့ စာအာလံုးကိုရွင္းလင္းေပးဖို့ပါ။
3)getch()-သူ ့ကိုေတာ့ အေျဖကို ျမင္ရေအာင္ အတြက္ screenေပၚမွာ ကီးဘုတ္မွ ကီးတစ္ခုခုမရိုက္မခ်င္း အေျဖကို ျပေနဖို့အတြက္ သံုးတာပါ။
4)getche()-သူ ့ကိုေတာ့ အေျဖကို ျမင္ရေအာင္ အတြက္ screenေပၚမွာ ကီးဘုတ္မွ ကီးကို တစ္ခါရိုက္လိုက္လွ်င္ screenေပၚမွာ အေျဖနွင့္ ရိုက္လိုက္ေသာ ကီးကို ျပေနဖို့အတြက္ သံုးတာပါ။
ကဲဒီေန့အဖို့ေတာ့ဒီေလာက္ပါပဲ။က်န္တာေတာ့ ေနာက္ေန့မွ ဆက္ေရးပါေတာ့မယ္။ အမွားပါရင္လည္း ျပင္ေပး က်ပါခင္ဗ်ာ။အခုကေတာ့ ညဥ့္နက္ေနလို့ပါ။ေက်းဇူးတင္ပါတယ္။

C++ အိမ္စာမ်ား(၉)

ဒီတစ္ပုဒ္ကေတာ့ Square Matrix ပါပဲခင္ဗ်။ Main Diagonal ရဲ႕ အထက္ပိုင္း (အစိမ္းေရာင္) entry ေတြဟာ -100 to 20 ကိန္းျဖစ္ရမွာျဖစ္ျပီး က်န္ေနရာေတြဟာ -1 to 50 ကိန္းေတြျဖစ္ရပါမယ္တဲ့ခင္ဗ်ာ။ အစိမ္းေရာင္ entry ေတြရဲ႕ row column ေတြမွာ j သည္ i ထက္ၾကီးပါတယ္ဆိုတဲ့ concept ေလးေတြးႏိုင္လိုက္ေတာ့ ေရးလို႔ ရသြားတာေပါ့ခင္ဗ်ာ။

html မွာ code ေတြ ဖဲ့ခ်န္ခဲ့လို႔ အျပည့္အစံုျဖစ္ေအာင္ print screen နဲ႔ပဲ ေဖၚျပလိုက္ရပါတယ္ခင္ဗ်ာ။



ရလာမယ့္အေျဖကေတာ့

ဆက္လက္ေရးသားသြားပါဦးမယ္ခင္ဗ်ာ။









C++ အိမ္စာမ်ား(၈)

ဒီတစ္ပုဒ္ကေတာ့ Square Matrix တစ္ခု ေဆာက္ခိုင္းတာပါခင္ဗ်။ ရလိုတဲ့အေျဖက ေအာက္ကပံုေလးအတိုင္းပဲ စံုေတြမေတြနဲ႔ Random တြက္ခ်င္ပါသတဲ့ခင္ဗ်ာ။
ဒီပုစၧာမွာေတာ့ ပထမ ပန္းေရာင္ ပထမတန္းအတြက္ i မကိန္းဆိုလွ်င္ j စံုကိန္းျဖစ္ေနတာနဲ႔ ဒုတိယတန္းအတြက္ i စံုကိန္းျဖစ္လွ်င္ j မကိန္းျဖစ္ေနတာနဲ႔ ကန္႔သတ္ေရးပါတယ္။
စံုကိန္းဆိုတာကေတာ့ ဘယ္ကိန္းကို ၂ နဲ႔ေျမွာက္ေျမွာက္ရတာေပါ့ခင္ဗ်ာ။ မကိန္းဆိုတာကလည္း ၂ နဲ႔ေျမွာက္ျပီး ၁ ႏႈတ္ေပါ့ဗ်ာ။

#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
void main()
{
int m,a[100][100];
cout<<"Enter the number of Row of square Matrix =\t";
cin>>m;
for (int i=0;i<m;i++)
for (int j=0;j<m;j++)
{
a[i][j]=rand()%10;
if ((i%2==0)&&(j%2==0)||(i%2!=0)&&(j%2!=0))
{
a[i][j]=a[i][j]*2;
}
else
a[i][j]=a[i][j]*2-1;
}

for (int i=0;i<m;i++)
{
cout<<'\n';
for (int j=0;j<m;j++)
{
cout<<a[i][j]<<" \t";
}
}
getch ();
}


အေျဖပံုစံကေတာ့

C++ အိမ္စာမ်ား(၇)

ဒီတစ္ပုဒ္ကေတာ့ -10 ကေန 10 ၾကားကို Random ေခါက္ခိုင္းတာပါခင္ဗ်။
rand()%20 က 0 ကေန 20 ထိၾကားကို ထုတ္ေပးမွာျဖစ္ပါတယ္။ သူ႔ကို 10 ႏႈတ္လိုက္တဲ့အခါမွာေတာ့ -10 to 10 ျဖစ္သြားပါေရာခင္ဗ်ာ။

#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
void main()
{
int m,a[100][100];
cout<<"Enter the number of Row of square Matrix =\t";
cin>>m;
for (int i=0;i<m;i++)
for (int j=0;j<m;j++)
{
a[i][j]=rand()%10;
if ((i%2==0)&&(j%2==0)||(i%2!=0)&&(j%2!=0))
{
a[i][j]=a[i][j]*2;
}
else
a[i][j]=a[i][j]*2-1;
}

for (int i=0;i<m;i++)
{
cout<<'\n';
for (int j=0;j<m;j++)
{
cout<<a[i][j]<<" \t";
}
}
getch ();
}


အေျဖကေတာ့

C++ အိမ္စာမ်ား(၆)

ဒီတစ္ခါပုစၧာကေတာ့ 1 ကေနစတဲ့ integer ေတြကို Row ကေန မဟုတ္ဘဲ Column လိုက္စီထည့္သြားမွာျဖစ္ပါတယ္ခင္ဗ်။

#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
void main()
{
int m,n,a[100][100];
cout<<"Enter the number of Row =\t";
cin>>m;
cout<<"Enter the number of Column=\t";
cin>>n;
int start=1;
for (int j=0;j<n;j++)
for (int i=0;i<m;i++)
{
a[i][j]=start;
start++;
}
for (int i=0;i<m;i++)
{
cout<<'\n';
for (int j=0;j<n;j++)
{
cout<<a[i][j]<<" \t";
}
}
getch ();
}
ရလာမယ့္အေျဖကေတာ့

9Dragon က MgGyi

ကၽြန္ေတာ္ လယ္ဗယ္တင္လိုက္တာ ဘယ္ေလာက္ေကာင္းလဲဆိုေတာ့ဗ်ာ 9Dragons Online Game က ဆာဗာ သံုးခုရွိတဲ့အနက္က အေမရိကန္ဆာဗာ Nivana ကေန ေအာက္ပါ link ကေန ေဖၚျပျခင္းခံရပါတယ္။ (ဟီး ဟီးၾကြားတာ)

http://phpbb.acclaim.com/9dragons/viewtopic.php?t=120016&start=0&postdays=0&postorder=asc&highlight=

login မရွိသူေတြအတြက္ ဒီလိုေဖၚျပထားပါတယ္ခင္ဗ်ာ။



Reply with quote
Warriors, I am pleased to announce the winners of the 9D Immortals Contest.

The task was to show how you might do it all differently were you to begin again, and many of you took Acclaim up on the offer. I wonder, did you find it easier the second time around? Did it make you nostalgic? Did you choose a very different path through The Land? First, I congratulate all who competed, I am sure it was an adventure, and training hard should have given you a taste of what it would be like to be under the tutelage of a true Sifu.

Now here we have 9 winners, each of whom having leveled up the highest, all of whom having been painstakingly verified by our noble GMs (and we apologize for the delay but there are a few new bugs ingame that could have been utilized to cheat... and we needed to make sure they had not been employed, in fairness, hence the delay). I find it quite heartwarming that Non-Item Mall Users earned second place on both Bardo and Asura instead of third place as promised!

These 9 will now each take on an Immortal Character and walk The Land for a little over a month. Some will be light, others dark, each according to their own path. A Post will also be created for each along with a screenshot (so you will know them when you see them), and we hope they shall chronicle their adventures. For rights of privacy, I shall not name their ingame Main Characters... though they may do so in the posts as they wish.


Nirvana Immortal Winners:

Acct Char Name Level
1) firestorm StormmWor1d 157
2) lithomas12 PumpkinQueen 148
3) colorlessqua MgGyi 144 (Non Item Mall User)

ဒီ ဆာဗာ မွာေတာ့ တတိယ ေနရာလိုက္တယ္ေပါ့ခင္ဗ်ာ။


ဒါကေတာ့ MgGyi ရဲ႕ ရုပ္သြင္ သ႑န္ေလးေပါ့ခင္ဗ်ာ။
လယ္ဘယ္နဲ႔ ဆင္ထားတာေလးေတြကေတာ့ အႏုတ္စုတ္ ဂုတ္စုတ္ေလးပါ။


 

သြားလည္တတ္တဲ့ဖိုရမ္ေတြက

Subscribe Subscribe Subscribe

ေတာင္းပန္စကား

ငါတတ္ငါေတာ္ ငါအေက်ာ္ဟု၊ ငါေသာ္စိတ္ထား မရွိျငားလည္း၊ ငါကားငယ္ရြယ္ ဥာဏ္မၾကြယ္၍၊ အဘယ္သုိ႔လွ်င္ အမွားစင္အံ့၊ အၾကင္သူေတာ္ ပညာေက်ာ္သည္၊ ခၽြတ္ေခ်ာ္လြဲမွား ငါ့စကားကုိ၊ စိတ္ထားေဖြးျဖဴ ျပင္ေတာ္မူ။ (ရွင္အဂၢဥာဏ)

အေမာင့္ကိုေျပာခဲ့ခ်င္ရင္

လာလည္ၾကသူမ်ား

လာလည္ၾကၾကိမ္ေပါင္း

ဖတ္ၾကတဲ့ စာမ်က္ႏွာအေရအတြက္