Cov txheej txheem:

C ++ Basic Program: 11 Kauj Ruam
C ++ Basic Program: 11 Kauj Ruam

Video: C ++ Basic Program: 11 Kauj Ruam

Video: C ++ Basic Program: 11 Kauj Ruam
Video: C Programming Tutorial for Beginners 2024, Kaum ib hlis
Anonim
C ++ Basic Program
C ++ Basic Program

hauv qhov haujlwm no koj yuav kawm paub pib c ++ los ntawm kev coding yooj yim c ++ program los ua ntau tus neeg siv thiab tso saib cov neeg siv no, vam tias koj yuav txaus siab !!!!!!!

Kauj ruam 1: #suav nrog Cov Ntaub Ntawv

kauj ruam 1- ua ntej, peb yuav tsum suav nrog lub tsev qiv ntawv peb yuav siv:

#suav nrog

#suav nrog

#suav nrog

Kauj Ruam 2: Tshaj Tawm Peb Txoj Haujlwm Tseem Ceeb

theem 2- tam sim no peb yuav tsum tshaj tawm peb lub luag haujlwm tseem ceeb hauv txoj haujlwm:

int lub ntsiab ()

{

rov 0;

}

Kauj Ruam 3: Tshaj Tawm Peb Qhov Hloov Pauv

tam sim no peb yuav tsum tshaj tawm txhua qhov kev hloov pauv uas peb yuav siv hauv txoj haujlwm:

std:: cov neeg siv hlua;

xaiv char;

std:: vector cov neeg siv;

Kauj Ruam 4: Ua Peb Lub Loop Loj

tam sim no peb yuav tsum tau ua tus lej ua-thaum lub voj:

ua

{

} thaum (xaiv! = "q" thiab xaiv! = "Q");

Kauj Ruam 5: Ua Cov Ntawv Qhia Tseem Ceeb

tam sim no sab hauv lub ntsiab lus cia cov lej yog cov ntawv qhia zaub mov tseem ceeb:

std:: cout << "------------------------------------------------------- -"<< std:: endl; std:: cout << "a - ntxiv tus neeg siv" << std:: endl;

std:: cout << "d - tso saib txhua tus neeg siv" << std:: endl;

std:: cout << "q - tawm" << std:: endl;

Kauj Ruam 6: Nug rau Tus Neeg Siv Xaiv

tam sim no peb yuav tsum nug tus neeg siv seb lawv xav ua dab tsi thiab khaws qhov ntawd hauv qhov sib txawv xaiv:

std:: cout << "thov xaiv ib qho";

std:: cin >> xaiv;

Kauj Ruam 7: Txheeb Xyuas Yog Tus Neeg Siv Khoom Siv Tau = "A"

tam sim no yog tias tus neeg siv "A", peb yuav tsum ua tus neeg siv thiab khaws nws hauv peb cov vector:

yog (xaiv == 'a' lossis xaiv == 'A') {

std:: cout << "thov ntaus cov neeg siv lub npe";

std:: cin >> neeg siv;

users.push_back (neeg siv);

std:: cout << "tus neeg siv tau ua tiav ntxiv" << std:: endl;

}

Kauj Ruam 8: Txheeb Xyuas Yog tias Tus Neeg Siv Khoom Siv Tau = "D"

yog tias tus neeg siv cov tswv yim yog "D" thiab tsis yog "A" ces peb yuav tsum tso saib txhua tus neeg siv hauv peb cov vector siv qhov yooj yim rau lub voj:

lwm tus yog (xaiv == 'd' lossis xaiv == 'D') {

std:: cout << "nov yog txhua tus neeg siv:" << std:: endl;

rau (pib siv: *users.data ())

{

std:: cout << siv << std:: endl;

}

}

Kauj Ruam 9: Txheeb Xyuas Yog Tus Neeg Siv Cov Lus Qhia Yog = "Q"

yog tias tus neeg siv tswv yim yog = "Q" ces peb yuav tsum hais "sib ntsib" ces lub voj yuav xaus thiab yog li qhov program yuav:

lwm tus yog (xaiv == 'q' lossis xaiv == 'Q') {

std:: cout << "nyob zoo" << std:: endl;

}

Kauj Ruam 10: Txheeb Xyuas Lwm Yam

yog tias kev siv tso rau lwm yam uas peb tsis nkag siab peb yuav tso tawm cov lus yuam kev:

lwm tus std:: cout << "hmmmm, Kuv tsis paub qhov hais kom ua" << std:: endl;

Kauj Ruam 11: Peb Ua Tiav !!!!!!

tam sim no peb tau ua tiav, tam sim no koj tuaj yeem sim koj li program thiab muaj kev lom zem nrog nws, ua tsaug !!!!!!