Basic Input Output
C++ မွာ input /output header file ၃ ခုရွိပါတယ္ ။
#include <iostream> // ရိုးရိုး input / output ေတြအတြက္ပါ ။
#include <fstream> // file I/O ေတြအတြက္ပါ ။
#include <iomanip> // manipulation format ေတြအတြက္ပါ ။
Insertion Operator (<<)
Extraction Operator(>>)
cout ဆိုတာက console output ပါ ။ standard library file iostream ေအာက္မွာရွိပါတယ္ ။ သူကဘာလုပ္ေပးလဲဆိုေတာ႔ object cout မွာရွိတဲ႔
တန္ဖိုးေတြကို Insertion Operator (<<)နဲ႔ secreen မွာျပေပးပါတယ္ ။
cin ဆိုတာကေတာ႔ console input ပါ ။ သူရဲ့အလုပ္ကေတာ႔ ကီးဘုတ္ကရိုက္ေပးလိုက္တဲ႔ value ေတြကို Extration Operator အကူညီနဲ႔
Variable ေတြထဲမွာထည့္ေပးဖို႔ပါပဲ ။
#include <iostream>
#include <iomanip>
using namespace std;
void main()
{
//this is my second program
int iTimes;
cout<<"@ Wellcome from www.technohalo.com @\n\n";
cout<<"How many times you reach in here : ";
cin>>iTimes;
cout<<"\n\nWow ! really "<<iTimes<<" times ? \n\nWe want to meet you again .\n\n"<<endl;
//using width
cout.width(3);cout<<"7 ";
cout.width(1);cout<<"7 ";
cout.width(1);cout<<"7" <<endl;
cout.width(5);cout<<"7" <<endl;
cout.width(4);cout<<"7" <<endl;
cout.width(3);cout<<"7" <<endl;
cout.width(2);cout<<"7" <<endl;
cout<<"\n\n\n";
//using setw
cout<<setw(5)<<"*"<<setw(1)<<"*"<<setw(4)<<"*"<<setw(1)<<"*"<<endl;
cout<<setw(4)<<"*"<<setw(3)<<"*"<<setw(2)<<"*"<<setw(3)<<"*"<<endl;
cout<<setw(3)<<"*"<<setw(5)<<"*"<<setw(5)<<"*"<<endl;
cout<<setw(4)<<"*"<<setw(8)<<"*"<<endl;
cout<<setw(5)<<"*"<<setw(6)<<"*"<<endl;
cout<<setw(6)<<"*"<<setw(4)<<"*"<<endl;
cout<<setw(7)<<"*"<<setw(2)<<"*"<<endl;
cout<<setw(8)<<"*"<<endl;
}
ရွင္းလင္းခ်က္
အေပၚမွာလည္း ေျပာျပခဲ႔ၿပီးပါၿပီ Input output ေတြဘယ္လိုအလုပ္လုပ္လဲဆိုတာ ။ ဥပမာ ေရးျပတာကေတာ႔ပိုၿပီးျမင္သာေအာင္လို႔ပါ ။
ဒီprogram ထဲမွာေတာ႔ #include< iomanip> ကိုသံုးထားပါတယ္ ။ setw ဆိုတာကေတာ႔ set width ကိုဆိုလိုတာပါ ။ iomanip ဖိုင္ေအာက္မွာရွိပါတယ္ ။ secreen မွာကိုျပခ်င္တဲ႔ပံုစံ မ်ိဳးျပနိုင္ေအာင္ အတြက္ အသံုးဝင္ပါတယ္ ။
ေလ႔က်င္႔ခန္း
ဘယ္ေလာက္ပဲနားလည္နားလည္ ကိုယ္တုိင္ လုပ္ၾကည့္မွကိုယ္ပိုင္အသိရမွာပါ ။ အဲဒါေၾကာင္႔ ကိုယ္တိုင္လုပ္ၾကည့္ခ်င္တယ္ဆိုရင္ေတာ႔ အေပၚက ဥပမာမွာ ကၽြန္ေတာ္ 7 နဲ႔ ့heart ပံုစံေလးကိုေရးျပထားပါတယ္ ။ေနာက္ထပ္ထပ္ၿပီး A ပံုစံေတြ 3 ပံုစံေတြ စသျဖင္႔ေပါ႔ေလကိုယ္စိတ္ကူးတည့္ရာလုပ္ၾကည့္ၾကပါလို႔ တိုက္တြန္းလိုပါတယ္ ။
ေဆြးေႏြးခ်က္(၁)
Sunday, June 27, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment