Cov txheej txheem:

FLAMES Siv C ++: 8 Kauj Ruam
FLAMES Siv C ++: 8 Kauj Ruam

Video: FLAMES Siv C ++: 8 Kauj Ruam

Video: FLAMES Siv C ++: 8 Kauj Ruam
Video: CVPR 2020 Workshop: Luca Carlone 2024, Hlis ntuj nqeg
Anonim
FLAMES Siv C ++
FLAMES Siv C ++
FLAMES Siv C ++
FLAMES Siv C ++

Nyob zoo cov phooj ywg, Peb txhua tus paub txog kev ua si nplaim taws. Lol, Nws yog ib qho kev ua si lom zem tshaj plaws uas ua rau peb thaum yau muaj kev zoo siab dua. Hauv cov lus qhia no, peb yuav pom yuav ua li cas rau txheej txheem txheej txheem nplaim taws siv C ++ lus.

Kauj Ruam 1: Lub Tswv Yim Siv

Tswv yim Siv
Tswv yim Siv

Ntawm no kuv tau siv Daim Ntawv Txuas Txuas ob npaug.

Kauj Ruam 2: Lub luag haujlwm tseem ceeb

int lub ntsiab ()

{

kab npe 1, npe 2;

koj n1, n2. cout << "ENTER FIRST NAME:"; getline (cin, npe 1); cout << "ENTER SECOND NAME:"; getline (cin, npe 2);

}

Ua ntej, peb yuav tsum tau txais ob lub npe nrog qhov chaw yog li kuv siv cov getline () ua haujlwm kom tau txais txoj hlua nrog qhov chaw.

Kauj Ruam 3: Yuav Ua Li Cas Pom Cov Cim Tshwj Xeeb?

void emit (hlua & a)

{

rau (int i = 0; a ! = '\ 0'; i ++)

{

yog (a > = 'a' && a <= 'z') {}

lwm tus yog (a > = 'A' && a <= 'Z') {}

lwm tus

ib = '0';

}

}

Tam sim no, peb yuav tsum tshem cov cim tshwj xeeb zoo li &, $, '' … thiab lwm yam. Los ntawm kev siv txoj haujlwm no peb tshem tawm txhua tus cim uas tsis yog cov tsiaj ntawv. Ntawm no, tsis txhob tshem tawm, kuv hloov nws nrog '0'.

Kauj Ruam 4: Tshem Tawm Cov Cim Zoo ib yam

rau (i = 0; name1 ! = '\ 0'; i ++)

rau (j = 0; name2 [j]! = '\ 0'; j ++)

yog ((name1 == name2 [j] || name1 == name2 [j] +32))

{

npe 1 = '0';

npe2 [j] = '0';

tawg;

}

Nws yog thawj kauj ruam ntawm kev ua si nplaim taws, Tias peb yuav tsum tshem cov cim qub uas nthuav tawm hauv ob lub npe. Tsab ntawv xov xwm no pab peb hloov tib lub cim los ntawm '0' thiab nws tseem ua haujlwm tau zoo txawm tias nws muaj ob qho ntawv loj thiab qis dua. Cov nqe lus tawg pab peb kom zam kev tshem cov cim rov ua dua.

j = 0; rau (i = 0; name1 ! = '\ 0'; i ++)

yog (name1 ! = '0')

j ++;

rau (i = 0; name2 ! = '\ 0'; i ++)

yog (name2 [kuv]! = '0')

j ++;

yog (j == 0) cout << "NO FLAMES";

Ntawm no, peb tshem tawm tag nrho '0's uas muaj nyob hauv ob lub npe. Yog li ntawd, thaum kawg, txhua yam zoo ib yam, cov cim raug tshem tawm. Tom qab ntawd j tau nce ntxiv tias nws yog suav ntawm cov tsiaj ntawv uas muaj nyob hauv ob lub npe tom qab tshem tib cov cim. Tam sim no peb yuav tsum txheeb xyuas seb nws muaj tsawg kawg ib tus cim lossis tsis yog. Txhawm rau ua kom cov cai muaj txiaj ntsig peb yuav tsum qhia tias tsis muaj peev xwm ua si cov nplaim taws yog tias nws tsis muaj cov cim tshwj xeeb.

Kauj Ruam 5: Tsim Cov Npe Txuas Doubly Txuas Sau

hlua a = "nplaim taws";

Ua ntej, tsim txoj hlua thoob ntiaj teb uas muaj "nplaim taws".

typedef struct node {

char cov ntaub ntawv;

ntawm *tom ntej, *ua ntej;

} ntawm;

node *sab saum toj = NULL, *temp;

Tam sim no, tsim cov qauv uas muaj cov ntaub ntawv tus yam ntxwv, tus pointer chaw nyob tom ntej, thiab tus lej chaw nyob yav dhau los.

Tom qab ntawd tsim tus taw tes uas taw tes rau sab saum toj ntawm cov npe sib txuas.

node* ins (char a) {

node *tshiab 1;

new1 = tshiab ntawm;

new1-> data = ua;

new1-> tom ntej = NULL;

new1-> prev = NULL;

yog (saum == NULL)

{

saum = new1;

temp = saum;

}

lwm tus

{

temp-> tom ntej = new1;

new1-> prev = temp;

temp = tshiab 1;

}

rov qab los saum;

}

Tom qab ntawd, ntxig cov hlua "nplaim taws" rau hauv cov npe txuas ob zaug los ntawm tus yam ntxwv.

void check (int j) {

int suav 1, chij = 0;

rau (int i = 0; a ! = '\ 0'; i ++)

saum = ins (a );

}

Kauj Ruam 6: Txoj Cai Ua Si Cov Hluav Taws

Code ua si nplaim taws
Code ua si nplaim taws

void check (int j)

{

int suav 1, chij = 0;

rau (int i = 0; a ! = '\ 0'; i ++)

saum = ins (a );

node *cur = top, *prev1;

temp-> tom ntej = saum;

top-> ua ntej = temp;

thaum (1)

{

suav 1 = 1;

thaum (suav 1 <j)

{

cur = cur-> tom ntej;

suav 1 ++;

}

ntawm *temp1 = cur;

prev1 = cur-> ua ntej;

cur-> prev-> next = cur-> tom ntej;

cur-> next-> prev = cur-> prev;

temp1-> tom ntej = NULL;

dawb (temp1);

cur = prev1-> tom ntej;

node *xeem = cur;

yog (xeem-> cov ntaub ntawv == xeem-> tom ntej-> cov ntaub ntawv)

tawg;

}

}

peb yuav tsum tau sau cov npe ncig uas yog "nplaim taws" txoj hlua raws li suav cov cim tshwj xeeb. Tom qab ntawd peb yuav tsum tshem tus cim hauv "nplaim taws" uas ua ke nrog suav. Peb yuav tsum paub txog kev siv cov npe sib txuas ua ob zaug hauv cov lej no. Nws pab tau ntau yam kom tshem tawm tus yam ntxwv tshwj xeeb. Nws tshem tawm tsis tu ncua. Txog thaum nws mus txog qhov xwm txheej uas tib cov cim tuaj ntau zaus.

yog (xeem-> cov ntaub ntawv == xeem-> tom ntej-> cov ntaub ntawv) tawg;

Kauj Ruam 7: Qhia Qhov Tseeb

hloov (cur-> cov ntaub ntawv)

{

case 'f': cout << "phooj ywg &&";

tawg;

case 'l': cout << "HLUB <3";

tawg;

rooj plaub 'a': cout << "AFFECTION $";

tawg;

case 'm': cout << "MARRIAGE:)";

tawg;

case 'e': cout << "YEEB YAM:(";

tawg;

case 's': cout << "SIBLING";

tawg; }

Siv cov lus hloov pauv no los qhia qhov tshwm sim zaum kawg uas yog tus cim zaum kawg tom qab tshem tag nrho lwm cov cim raws li suav.

Tam sim no koj tuaj yeem ua nplaim taws yooj yim los ntawm kev nkag mus rau cov npe, Nws yog txoj cai funny. Ua si qhov kev ua si no siv koj tus phooj ywg lub npe thiab ua rau lawv npau taws LOL. Ua tsaug.

Kauj Ruam 8: Txoj Cai rau Nplaim Taws

Cov lej ua tiav rau FLAMES muaj nyob ntawm no, github.com/naveeen684/Flames-code-using-C-/tree/master