Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <stdlib.h>
  4. #include <cstring>
  5. #include <conio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. //#include "f1.h"
  9. #include <stdio.h>
  10.  
  11. int n=0;
  12. struct spisoc
  13. {
  14. struct spisoc *next=NULL;
  15. int el=0;
  16. struct stek *stc;
  17. };
  18.  
  19. struct stek
  20. {
  21. struct stek *nex=NULL;
  22. struct stek *back=NULL;
  23. int el=0;
  24. };
  25. struct spisoc *firt=NULL;// (struct spisoc*)malloc(sizeof( struct spisoc)); óêàçàòåëü íà íà÷àëî
  26. struct spisoc *rab=NULL;
  27. struct spisoc *pos=NULL;// óêàçàòåëü íà ïîñëåäíèé
  28. struct spisoc *tn=firt;
  29. struct spisoc *tr=firt;
  30. struct stek *fin=NULL;
  31. struct stek *se=NULL;
  32. struct stek *fr= NULL;//(struct stek*)malloc(sizeof( struct stek));
  33. struct stek *rb= NULL;
  34. int flag_s=0;
  35. int flag_d=0;
  36.  
  37.  
  38.  
  39. using namespace std;
  40.  
  41. int dostup()
  42. {
  43. int a=0,b=0,c;
  44. char c1[]="1234";
  45. char c11[]="max";
  46. char c2[4],c3[3];
  47. printf("vvedire loginl: ");
  48. scanf("%3c3",&c3);
  49. b=strcmp(c11,c3);
  50. if(b!=0)
  51. {
  52. printf("nepravelni login !%s!%s!\n",c2,c3);
  53. }
  54. printf("vvedire porol: ");
  55. scanf("%s",&c2);
  56.  
  57. printf("\n");
  58. system("cls");
  59.  
  60.  
  61. a=strcmp(c1,c2);
  62. if(a!=0)
  63. {
  64. printf("nepravelni porol\n");
  65. }
  66. getch();
  67. system("cls");
  68. while((a!=0)||(b!=0))
  69. {
  70. printf("vvedire ecpe raz\n");
  71. printf("vvedire loginl: ");
  72. scanf("%s",&c3);
  73. b=strcmp(c11,c3);
  74. if(b!=0)
  75. {
  76. printf("nepravelni login\n");
  77. }
  78. printf("vvedire porol: ");
  79. scanf("%s",&c2);
  80. printf("\n");
  81. system("cls");
  82.  
  83. a=strcmp(c1,c2);
  84. if(a!=0)
  85. {
  86. printf("nepravelni porol\n");
  87. }
  88. }
  89.  
  90.  
  91. return a;
  92. }
  93.  
  94. void stekvnul (void);
  95. void proverkanul (void);
  96. void pokazvershni (void);
  97. void deletveshin (void);
  98. void vzitel (void);
  99. void izmenvwrshin (void);
  100. void dobavit (void);
  101. void raspechat (void);
  102.  
  103. void spisvnul (void);
  104. void provenanul (void);
  105. void printstart (void);
  106. void printfinish (void);
  107. void deletstart (void);
  108. void deletefinesh (void);
  109. void vzytstart (void);
  110. void vzytfin (void);
  111. int izmenstart (void);
  112. int izmenfin (void);
  113. void givenstart (void);
  114. void givenfin (void);
  115. void printst (void);
  116.  
  117.  
  118.  
  119.  
  120. int main(int argc, char** argv) {
  121. int flag=0,a=0,b, fff = 0, fff2 = 0;
  122. // flag = dostup();
  123.  
  124. while(flag==0)
  125. {
  126. /*
  127. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  128. printf("%c1 nachat rabotu co ctekom %c\n",178,178);
  129. printf("%c2 nachat raboru co srocami %c\n",178,178);
  130. printf("%c0 zaconcht rabotu %c\n",178,178);
  131. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  132. printf("vvedite ¹ comandi:");
  133. scanf("%d",&a);
  134. system("cls");*/
  135. a=2;
  136. if(a==1){
  137. while(flag==0)
  138. {
  139. z:
  140. system("cls");
  141. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  142. printf("%c1 nachat rabotu co stekom %c\n",178,178);
  143. printf("%c2 sdelat stek pustim %c\n",178,178);
  144. printf("%c3 proverka stek pust/ ne pust %c\n",178,178);
  145. printf("%c4 pokazat vershini stek %c\n",178,178);
  146. printf("%c5 ydalit vershini stek %c\n",178,178);
  147. printf("%c6 vzit element vershini steka %c\n",178,178);
  148. printf("%c7 izminit znacheniy vershini steka %c\n",178,178);
  149. printf("%c8 dobavit element v stek %c\n",178,178);
  150. printf("%c9 raspechatat stuct danih %c\n",178,178);
  151. printf("%c10 zaconcht rabotu %c\n",178,178);
  152. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  153.  
  154. printf("vvedite comandi:");
  155. scanf("%d",&a);
  156. system("cls");
  157.  
  158. switch ( a) {
  159. case 1:
  160. printf ("Vi nachali rabotu\n");
  161. getch();
  162. fff = 1;
  163. break;
  164. case 2:
  165. if (fff==1)
  166. stekvnul();
  167. else
  168. printf ("Vi ne nachali rabotu\n");
  169. getch();
  170.  
  171. break;
  172.  
  173. case 3:
  174. if (fff==1)
  175. proverkanul();
  176. else
  177. printf ("Vi ne nachali rabotu\n");
  178. getch();
  179.  
  180. break;
  181.  
  182. case 4:
  183. if (fff==1)
  184. {pokazvershni();
  185. goto a;}
  186. else
  187. printf ("Vi ne nachali rabotu\n");
  188. getch();
  189.  
  190. break;
  191.  
  192. case 5:
  193. if (fff==1)
  194. {
  195. deletveshin();
  196. goto a;}
  197. else
  198. printf ("Vi ne nachali rabotu\n");
  199. getch();
  200.  
  201. break;
  202.  
  203. case 6:
  204. if (fff==1)
  205. {
  206. vzitel();
  207. goto a;
  208. }
  209. else
  210. printf ("Vi ne nachali rabotu\n");
  211. getch();
  212.  
  213. break;
  214.  
  215. case 7:
  216. if (fff==1)
  217. {
  218. izmenvwrshin();
  219. goto a;
  220. }
  221. else
  222. printf ("Vi ne nachali rabotu\n");
  223. getch();
  224.  
  225. break;
  226.  
  227. case 8:
  228. if (fff==1)
  229. {
  230. if (flag_s>4)
  231. printf("Slishkom mnogo elementov\n");
  232. else
  233. {
  234. dobavit();
  235. goto a;
  236. }
  237. }
  238. else
  239. printf ("Vi ne nachali rabotu\n");
  240. getch();
  241.  
  242. break;
  243.  
  244. case 9:
  245. if (fff==1)
  246. {
  247. a:
  248. raspechat();
  249. getch();
  250. system("cls");
  251. }
  252. else
  253. printf ("Vi ne nachali rabotu\n");
  254. getch();
  255.  
  256. break;
  257.  
  258. case 10:
  259. flag=1;
  260.  
  261. break;
  262.  
  263. default:
  264. break;
  265. }
  266. }
  267. }
  268.  
  269. if(a==2){
  270. while(flag==0)
  271. {
  272. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  273. printf("%c1 nachat rabotu s decom %c\n",178,178);
  274. printf("%c2 sdelat dec pustim %c\n",178,178);
  275. printf("%c3 proverka stek pust/ ne pust %c\n",178,178);
  276. printf("%c4 pokazat znachenie eleenta vnachelt %c\n",178,178);
  277. printf("%c5 pokazat znachenie eleenta v konce %c\n",178,178);
  278. printf("%c6 ydalit eleent v nachale %c\n",178,178);
  279. printf("%c7 ydalit eleent v konce %c\n",178,178);
  280. printf("%c8 vzitie eleenta 1 %c\n",178,178);
  281. printf("%c9 vzitie eleenta n-go %c\n",178,178);
  282. printf("%c10 izminit eleenta 1 %c\n",178,178);
  283. printf("%c11 izminit eleenta n-go %c\n",178,178);
  284. printf("%c12 dobavit eleenta v start %c\n",178,178);
  285. printf("%c13 dobavit eleenta v finishe %c\n",178,178);
  286. printf("%c14 raspechatat stuct danih %c\n",178,178);
  287. printf("%c15 zaconcht rabotu %c\n",178,178);
  288. printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c\n",178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178);
  289. printst ();
  290. printf("vvedite comandi:");
  291.  
  292. scanf("%d",&a);
  293. system("cls");
  294. int fg;
  295. switch ( a) {
  296. case 1:
  297. fff2 = 1;
  298. printf ("Vi nachali rabotu\n");
  299.  
  300. case 2:
  301. if (fff2 == 1)
  302. spisvnul ();
  303. else
  304. printf ("Vi ne nachali rabotu\n");
  305. getch();
  306. break;
  307.  
  308. case 3:
  309. if (fff2 == 1)
  310. provenanul ();
  311. else
  312. printf ("Vi ne nachali rabotu\n");
  313. getch();
  314.  
  315. break;
  316.  
  317. case 4:
  318. if (fff2 == 1)
  319. printstart ();
  320. else
  321. printf ("Vi ne nachali rabotu\n");
  322. getch();
  323.  
  324. break;
  325.  
  326. case 5:
  327. if (fff2 == 1)
  328. printfinish ();
  329. else
  330. printf ("Vi ne nachali rabotu\n");
  331. getch();
  332.  
  333. break;
  334.  
  335. case 6:
  336. if (fff2 == 1)
  337. deletstart ();
  338. else
  339. printf ("Vi ne nachali rabotu\n");
  340. getch();
  341.  
  342. break;
  343.  
  344. case 7:
  345. if (fff2 == 1)
  346. deletefinesh ();
  347. else
  348. printf ("Vi ne nachali rabotu\n");
  349. getch();
  350.  
  351. break;
  352.  
  353. case 8:
  354. if (fff2 == 1)
  355. vzytstart ();
  356. else
  357. printf ("Vi ne nachali rabotu\n");
  358. getch();
  359.  
  360. break;
  361.  
  362. case 9:
  363. if (fff2 == 1)
  364. vzytfin ();
  365. else
  366. printf ("Vi ne nachali rabotu\n");
  367. getch();
  368.  
  369. break;
  370.  
  371. case 10:
  372. if (fff2 == 1)
  373. //{
  374. {//deletstart ();
  375. //givenstart ();
  376.  
  377. fg=izmenstart ();
  378. if(fg==1){
  379. goto z;}
  380. }
  381. else
  382. printf ("Vi ne nachali rabotu\n");
  383. getch();
  384.  
  385.  
  386. break;
  387.  
  388. case 11:
  389. if (fff2 == 1)
  390. //{
  391. {
  392. fg=izmenfin ();
  393. if(fg==1){
  394. // deletefinesh();
  395. //givenfin();
  396. goto z;}
  397. }
  398. else
  399. printf ("Vi ne nachali rabotu\n");
  400. getch();
  401.  
  402. break;
  403.  
  404. case 12:
  405. if (fff2 == 1)
  406. {
  407. if(flag_d>4)
  408. printf ("Slishkom mnogo elementov\n");
  409. else{
  410. givenstart ();
  411. goto z;
  412. }
  413. }
  414. else
  415. printf ("Vi ne nachali rabotu\n");
  416. getch();
  417.  
  418. break;
  419.  
  420. case 13:
  421. if (fff2 == 1)
  422. {
  423. if (flag_d>4)
  424. printf ("Slishkom mnogo elementov\n");
  425. else
  426. {givenfin ();goto z;}
  427. }
  428. else
  429. printf ("Vi ne nachali rabotu\n");
  430. getch();
  431.  
  432. break;
  433.  
  434. case 14:
  435. if (fff2 == 1)
  436. printst ();
  437. else
  438. printf ("Vi ne nachali rabotu\n");
  439. getch();
  440.  
  441. break;
  442.  
  443. case 15:
  444. {flag=1;
  445. system("cls");
  446. exit(0);
  447. }
  448. break;
  449.  
  450. default:
  451. break;
  452. }
  453. }}
  454.  
  455. if(a!=0)
  456. {
  457. flag=0;
  458. }
  459. else
  460. {
  461. flag=1;
  462. }
  463.  
  464. }
  465.  
  466.  
  467. return 0;
  468. }
  469. // stek/////////////////////////////////////////////////////////////////////
  470.  
  471. void stekvnul(void)
  472. {
  473. rb=NULL;
  474. printf("SRABOTALO\nstrukt delete\n");
  475. flag_s = 0;
  476. getch();
  477. system("cls");
  478. }
  479.  
  480. void proverkanul (void)
  481. {
  482. if(rb==NULL)
  483. {
  484. printf("stek PUST");
  485. }
  486. else
  487. {
  488. printf("stek NE PUST");
  489. }
  490. getch();
  491. system("cls");
  492.  
  493. }
  494.  
  495. void pokazvershni (void)
  496. {
  497. if (rb!=NULL)
  498. {
  499. printf("vershina steca: >%d< = %d %d %d\n",rb->el,rb->back,rb,rb->nex);
  500. }
  501. else
  502. printf ("stek pust\n");
  503. getch();
  504. system("cls");
  505. }
  506.  
  507. void deletveshin (void)
  508. {
  509. if (rb!=NULL)
  510. {
  511. fin=rb->back;
  512. rb=rb->back;
  513. rb->nex=NULL;
  514. printf("delete OK");
  515. }
  516. else
  517. printf ("stek pust\n");
  518. if (flag_s>=0)
  519. flag_s--;
  520.  
  521. getch();
  522. system("cls");
  523.  
  524. }
  525. void vzitel (void)
  526. {
  527. if (rb!=NULL)
  528. {
  529. printf("bil vzyt eement: >%d< = %d %d %d\n",rb->el,rb->back,rb,rb->nex);
  530. fin=rb->back;
  531. rb=rb->back;
  532. rb->nex=NULL;
  533. printf("delete OK");
  534. }
  535. else
  536. printf ("stek pust\n");
  537. if (flag_s>=0)
  538. flag_s--;
  539.  
  540. getch();
  541. system("cls");
  542. }
  543. void izmenvwrshin (void)
  544. {
  545. int b;
  546. if (rb!=NULL)
  547. {
  548. printf("vvedite chislo: ");
  549. scanf("%d",&b);
  550. rb->el=b;
  551. }
  552. else
  553. printf ("stek pust\n");
  554.  
  555. getch();
  556. system("cls");
  557. }
  558. void dobavit (void)
  559. {
  560. int b,t=0;
  561. printf("vvedite chislo: ");
  562. scanf("%d",&b);
  563. if(rb==NULL)
  564. {
  565. printf("SRABOTALO\n");
  566. rb=( stek*)malloc(sizeof( struct stek));
  567.  
  568. rb->back=NULL;
  569. rb->el=b;
  570. rb->nex=NULL;
  571. fin=rb;
  572. printf("%d = %d %d %d\n",rb->el,rb->back,rb,rb->nex);
  573. t=1;
  574. }
  575. if((rb!=NULL)&&(t==0))
  576. {
  577. rb->nex = ( stek*)malloc(sizeof( struct stek));
  578. se=rb;
  579. rb=rb->nex;
  580. rb->back=se;
  581. rb->el=b;
  582. rb->nex=NULL;
  583. fin=rb;
  584. printf("%d = %d %d %d\n",rb->el,rb->back,rb,rb->nex);
  585. }
  586. // fin=rb;
  587. tn->stc=rb;
  588. flag_s++;
  589.  
  590. getch();
  591. system("cls");
  592. }
  593.  
  594. void raspechat (void)
  595. { int flag=0;;
  596. //fin=rb;
  597. tn->stc=rb;
  598. printf("znachenie steca: ");
  599. while (rb!=NULL)
  600. {
  601. if(flag==0){
  602. printf(">");
  603. }
  604. printf("%d ",rb->el);
  605. if(flag==0){
  606. printf("<");
  607. flag=1;
  608. }
  609. // printf("= %d %d %d\n",rb->back,rb,rb->nex);
  610. rb=rb->back;
  611. }
  612. rb=tn->stc;
  613. printf ("bolshe nechego pechatat");
  614. }
  615. // dec///////////////////////////////////////////////////////////////////////////
  616.  
  617.  
  618.  
  619. void spisvnul (void) //2
  620. {
  621. printf("structura dec delete\n");
  622. tn=NULL;
  623. rab=NULL;
  624. firt=NULL;
  625. printf("structura dec delete\n");
  626. getch();
  627. flag_d = 0;
  628. flag_s = 0;
  629. system("cls");
  630. n=0;
  631. }
  632. void provenanul (void) //3
  633. {
  634. rab=firt;
  635. if(rab==NULL)
  636. {
  637. printf("dec PUST");
  638. }
  639. else
  640. {
  641. printf("dec NE PUST");
  642. }
  643. getch();
  644. system("cls");
  645. }
  646.  
  647.  
  648. void printstart (void) //4
  649. {
  650.  
  651.  
  652. if(firt!=NULL)
  653. {
  654. printf("element v nachale deca: %d\n",firt);
  655. rb=firt->stc;
  656. while(rb!=NULL)
  657. {
  658. printf ("stek: %d\n",rb->el);
  659. rb=rb->back;
  660. }
  661. printst();
  662. }
  663. else
  664. {
  665. printf ("y nas net elementov");
  666. }
  667.  
  668. // printst();
  669. getch();
  670. system("cls");
  671. }
  672. void printfinish (void) //5
  673. {
  674. if(pos!=NULL)
  675. {
  676. printf("element v konce deca: %d\n",pos);
  677. rb=pos->stc;
  678. while(rb!=NULL)
  679. {
  680. printf ("stek: %d\n",rb->el);
  681. rb=rb->back;
  682. }
  683. printst();
  684. }
  685. else
  686. {
  687. printf ("y nas net elementov");
  688. }
  689. getch();
  690. system("cls");
  691. }
  692. void deletstart (void) //6
  693. {
  694. if(firt!=NULL)
  695. {
  696. firt=firt->next;
  697. printf("delete OK");
  698. //raspechat();
  699. printst();
  700. }
  701. else
  702. { printf("struct ne suchestvuet \n");
  703. printf("delete ne OK\n");
  704. }
  705. if (flag_d>=0)
  706. flag_d--;
  707. flag_s = 0;
  708. getch();
  709. system("cls");
  710. }
  711. void deletefinesh (void) //7
  712. {
  713. if(firt!=NULL)
  714. {
  715. rab=firt;
  716. while(rab!=NULL)
  717. {
  718. if(rab->next==pos)
  719. {
  720. pos=rab;
  721. pos->next=NULL;
  722. }
  723. rab=rab->next;
  724. }
  725. printf("delete OK");
  726. //raspechat();
  727. printst();
  728. }
  729. else
  730. { printf("struct ne suchestvuet\n");
  731. printf("delete ne OK\n");
  732. }
  733. if (flag_d>=0)
  734. flag_d--;
  735. flag_s = 0;
  736. getch();
  737. system("cls");
  738. }
  739. void vzytstart (void) //8
  740. {
  741. printstart();
  742. deletstart();
  743.  
  744. }
  745. void vzytfin (void) //9
  746. {
  747. printfinish();
  748. deletefinesh();
  749. }
  750. int izmenstart () //10
  751. {
  752. flag_s = 0;
  753.  
  754. if(firt!=NULL){
  755. rb=firt->stc;
  756.  
  757. //deletstart();
  758. //givenstart();
  759. getch();
  760. system("cls");
  761. return 1;
  762.  
  763. }
  764. else
  765. {printf(" y nac net strectur nam ne c chem rabotat");
  766. getch();
  767. system("cls");
  768. return 0;
  769. }
  770.  
  771.  
  772. }
  773. int izmenfin () //11
  774. {
  775. flag_s = 0;
  776. if(firt!=NULL){
  777. rb=pos->stc;
  778.  
  779. //deletefinesh();
  780. //givenfin();
  781. getch();
  782. system("cls");
  783. return 1;
  784. }
  785. else
  786. {printf(" y nac net strectur nam ne c chem rabotat");
  787. getch();
  788. system("cls");
  789. return 0;
  790. }
  791.  
  792. }
  793. void givenstart (void) //12
  794. {
  795. if(firt==NULL)
  796. {
  797. printf("1 zashlo\n");
  798. firt=(struct spisoc*)malloc(sizeof( struct spisoc));
  799. printf("1 zashlo\n");
  800. pos=firt;
  801. printf("1 zashlo\n");
  802. firt->next=NULL;
  803. printf("1 zashlo\n");
  804. pos->next=NULL;
  805. printf("1 zashlo\n");
  806. rab=firt;
  807. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  808. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  809. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  810.  
  811. tn=firt;
  812.  
  813. }
  814. else
  815. {
  816. rab=firt;
  817. printf("2 zashlo\n");
  818. firt=(struct spisoc*)malloc(sizeof( struct spisoc));
  819. firt->next=rab;
  820.  
  821. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  822. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  823. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  824. tn=firt;
  825. }
  826.  
  827. printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  828. tn->stc=( stek*)malloc(sizeof( struct stek));
  829. stekvnul();
  830. /*
  831. if(firt->next==NULL)
  832. {
  833.  
  834. firt->stc=( stek*)malloc(sizeof( struct stek));
  835. stekvnul();
  836. }
  837. if(firt->next!=NULL)
  838. {
  839. rab=firt->next;
  840. rab->stc=( stek*)malloc(sizeof( struct stek));
  841. stekvnul();
  842. }*/
  843. flag_d++;
  844. flag_s = 0;
  845.  
  846. printf("NOW sozdan\n");
  847. getch();
  848. system("cls");
  849. }
  850. void givenfin (void) //13
  851. {
  852. if(firt==NULL)
  853. {
  854. printf("1 zashlo\n");
  855. firt=(struct spisoc*)malloc(sizeof( struct spisoc));
  856. pos=firt;
  857. firt->next=NULL;
  858. pos->next=NULL;
  859. rab=firt;
  860. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  861. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  862. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  863.  
  864. tn=pos;
  865.  
  866.  
  867. }
  868. else
  869. {
  870. if(firt->next==NULL)
  871. {
  872. rab=firt;
  873. printf("2 zashlo\n");
  874. pos->next=(struct spisoc*)malloc(sizeof( struct spisoc));
  875. firt->next=pos->next;
  876. rab=pos;
  877. pos=pos->next;
  878. pos->next=NULL;
  879. printf("rab = %d %d %d\n",rab,rab->next,rab->stc);
  880. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  881. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  882. tn=pos;
  883. }
  884. else
  885. {
  886. printf("3 zashlo\n");
  887. pos->next=(struct spisoc*)malloc(sizeof( struct spisoc));
  888. rab=pos;
  889. pos=pos->next;
  890. pos->next=NULL;
  891. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  892. printf("pos =%d %d %d\n",pos,pos->next,pos->stc);
  893. printf("firt =%d %d %d\n",firt,firt->next,firt->stc);
  894. tn=pos;
  895. }
  896.  
  897. }
  898. printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  899. tn->stc=( stek*)malloc(sizeof( struct stek));
  900. stekvnul();
  901.  
  902. flag_d++;
  903. flag_s = 0;
  904. printf("NOW sozdan\n");
  905. getch();
  906. system("cls");
  907. }
  908.  
  909. void printst (void) //14
  910. {
  911.  
  912. tn=firt;
  913. if(tn==NULL)
  914. printf("PUSTO\n");
  915. else
  916. printf("OK\n");
  917. while(tn!=NULL)
  918. {
  919. printf("DEC:\n");
  920. printf ("----------------\n");
  921. rb=tn->stc;
  922. while(rb!=NULL)
  923. {
  924. printf ("stek: %d\n",rb->el);
  925. rb=rb->back;
  926. }
  927.  
  928. tn=tn->next;
  929.  
  930. }
  931.  
  932. //getch();
  933. // system("cls");
  934. }
  935.  
  936. /*void printzaukaz (void) //7
  937. {
  938. if(tn->next!=NULL)
  939. {
  940. rab=tn->next;
  941. rb=rab->stc;
  942. printf("element za rabochim ucazatelem: %d %d %d\n",rab,rab->stc,rab->next);
  943. raspechat();
  944. }
  945. else
  946. {
  947. printf ("ucazatel v konce spica");
  948.  
  949. }
  950.  
  951.  
  952. getch();
  953. system("cls");
  954. }
  955. void deletezaukaz (void) //8
  956. {
  957. if(tn->next!=NULL)
  958. {
  959. rab=tn;
  960. rab=rab->next;
  961. tn->next=rab->next;
  962. rb=rab->stc;
  963. //printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  964. printf("delete OK");
  965. //raspechat();
  966. }
  967. else
  968. { printf("nash ukazatel naxoditsa v konse(rekomenduetsa ego peredvinut)\n");
  969. printf("delete ne OK\n");
  970. }
  971.  
  972. getch();
  973. system("cls");
  974. }
  975. void vzytzaukaz (void) //9
  976. {
  977. if(tn->next!=NULL)
  978. {
  979. rab=tn;
  980. rab=rab->next;
  981. rb=rab->stc;
  982. printf("vzytiy element za rabochim ucazatelem: >%d< %d %d",rab,rab->stc,rab->next);
  983. raspechat();
  984. tn->next=rab->next;
  985. printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  986. }
  987. else
  988. { printf("nash ukazatel naxoditsa v konse(rekomenduetsa ego peredvinut)");
  989. }
  990. getch();
  991. system("cls");
  992. }
  993. void izmenzaukaz (void) //10
  994. {
  995. if(tn->next!=NULL)
  996. {
  997. rab=tn->next;
  998. rab->stc=( stek*)malloc(sizeof( struct stek));
  999. //stekvnul();
  1000. }
  1001. else
  1002. {printf("nash ukazatel naxoditsa v konse(rekomenduetsa ego peredvinut)\n");
  1003. }
  1004. }
  1005. void givenzaukaz (void) //11
  1006. {
  1007. int o=1;
  1008. if(n==0&&rab==NULL)
  1009. {
  1010. n++;o=0;
  1011. printf("1 zashlo\n");
  1012. firt=(struct spisoc*)malloc(sizeof( struct spisoc));
  1013. rab=firt;
  1014. firt->next=rab;
  1015. rab->next=NULL;
  1016. tn=rab;
  1017. rab->el=n;
  1018. printf("rab =%d %d %d\n",rab,rab->next,rab->stc);
  1019. printf("tn =%d %d %d\n",tn,tn->next,tn->stc);
  1020. printf("firt=%d %d %d\n",firt,firt->next,firt->stc);
  1021.  
  1022. }
  1023. if((tn!=NULL)&&(tn->next==NULL)&&(o==1))
  1024. {
  1025. printf("2 zashlo\n");
  1026. rab=tn;
  1027. rab->next=(struct spisoc*)malloc(sizeof( struct spisoc));
  1028. rab=rab->next;
  1029. rab->next=NULL;
  1030. tn->next=rab;
  1031. printf("firt=%d %d %d\n",firt,firt->next,firt->stc);
  1032. printf("rab=%d %d %d\n",rab,rab->next,rab->stc);
  1033. printf("tn=%d %d %d\n",tn,tn->next,tn->stc);
  1034. n++;
  1035. rab->el=n;
  1036. o=0;
  1037. }
  1038. if((tn!=NULL)&&(tn->next!=NULL)&&(o==1))
  1039. {
  1040. printf("3 zashlo\n");
  1041.  
  1042.  
  1043. printf("tn=%d %d %d\n",tn,tn->next,tn->stc);
  1044. tr=(struct spisoc*)malloc(sizeof( struct spisoc));
  1045. printf("tr=%d %d %d\n",tr,tr->next,tr->stc);
  1046. rab=tn;
  1047. rab=rab->next;
  1048. printf("rab=%d %d %d\n",rab,rab->next,rab->stc);
  1049. tr->next=rab;
  1050. printf("tr=%d %d %d\n",tr,tr->next,tr->stc);
  1051. tn->next=tr;
  1052. printf("tn=%d %d %d\n",tn,tn->next,tn->stc);
  1053. //tr->stc=NULL;
  1054. rab=tr;
  1055.  
  1056. }
  1057.  
  1058. //tn->stc=NULL;
  1059. //rab->stc=NULL;
  1060. if(tn->next==NULL)
  1061. {
  1062.  
  1063. rab->stc=( stek*)malloc(sizeof( struct stek));
  1064. stekvnul();
  1065. }
  1066. if(tn->next!=NULL)
  1067. {
  1068. tn=tn->next;
  1069. rab->stc=( stek*)malloc(sizeof( struct stek));
  1070. stekvnul();
  1071. }
  1072.  
  1073.  
  1074. printf("NOW sozdan\n");
  1075. getch();
  1076. system("cls");
  1077. }
  1078. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement