Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <stdio.h>
- //#include <malloc.h>
- //#include <time.h>
- //#include <stdlib.h>
- //#include <conio.h>
- //using namespace std;
- //int main()
- //{
- // int *a,**b;
- // int i, n, m,r,j;
- // srand(50);
- // //r = rand();
- // //a = (int*)malloc(r* sizeof(int));
- //// for (i = 0; i < r; i++)
- //// a[i] = rand();
- // //n = rand();
- // n = 5;
- // m = 5;
- // b = (int**)malloc(n*sizeof(int*));
- // for (i = 0; i < n; i++)
- // {
- // b[i] = (int*)malloc(m * sizeof(int));
- // for (j = 0; j < m; j++)
- // b[i][j] = rand();
- // printf_s("%x \n", &b[i][j]);
- // }
- // for (i = 0; i < n; i++)
- // {
- // for (j = 0; j < m; j++)
- // printf_s("%d ", b[i][j]);
- // printf_s("\n");
- // free(b[i]);
- // }
- // free(b);
- // _getch();
- // return 0;
- //}
- //#include <stdio.h>
- //#include <malloc.h>
- //#include <time.h>
- //#include <stdlib.h>
- //#include <conio.h>
- //using namespace std;
- //struct data
- //{
- // int a;
- //};
- //struct list
- //{
- // struct data value;
- // struct list *next;
- // struct list *prev;
- //
- //};
- //int main()
- //{
- // srand(time(NULL));
- // int i;
- // struct list *head,*last,*p1,*p2;
- // head = (struct list*)malloc(sizeof(struct list));
- // head->value.a = rand();
- // head->next = NULL;
- // head->prev = NULL;
- // p1 = head;
- // for (i = 1; i < 5; i++)
- // {
- // p1->next=(struct list*)malloc(sizeof(struct list));//выделяю память для следующего элемента
- // p2 = p1->next;
- // p2->prev = p1;
- // p2->value.a = rand();
- // p2->next = NULL;
- // p1 = p2;
- //
- // }
- // last=p1;
- // p1 = head;
- // for (;p1!=NULL;)
- // {
- //
- // printf_s("%d ", p1->value.a);
- // p1 = p1->next;
- // }
- // printf_s("\n");
- // p1 = last;
- // for (; p1 != NULL;)
- // {
- //
- // printf_s("%d", p1->value.a);
- // p1 = p1->prev;
- // }
- // _getch();
- // return 0;
- //}
- //#include <stdio.h>
- //#include <malloc.h>
- //#include <time.h>
- //#include <stdlib.h>
- //#include <conio.h>
- //using namespace std;
- //
- //int main()
- //{
- // int nstr1,nstr2,istr1,istr2, i, j,k;
- // char *str1,*str12, *str2;
- // str1 = new char[256];
- // str2 = new char[256];
- // str12 = new char[256];
- // char c='a';
- // for (nstr1=0; c != '\n';nstr1++)
- // {
- // scanf_s("%c", &c);
- // str1[nstr1] = c;
- // }
- // c = 'a';
- // for (nstr2 = 0; c != '\n'; nstr2++)
- // {
- // scanf_s("%c", &c);
- // str2[nstr2] = c;
- // }
- // nstr2--;
- // for (istr1=nstr1-1; istr1 >= 0; istr1--)
- // {
- // if (str1[istr1] == str2[nstr2-1])
- // {
- // i = istr1;
- // k = 0;
- // for (j = nstr2 - 2; j>= 0; j--)
- // {
- // i--;
- // if (str2[j] == str1[i])k++;
- //
- // }
- // if (k == nstr2 - 1)
- // {
- // k = istr1+1;
- // for (istr1-=nstr2; istr1 >= 0; istr1--)
- // str12[istr1] = str1[istr1];
- // istr2 = k - nstr2;
- // for (istr1=k; istr1<nstr1; istr1++)
- // {
- // str12[istr2] = str1[istr1];
- // istr2++;
- // }
- // k = -1;
- // istr1 = -1;
- // }
- // }
- // }
- // if(k==-1)
- // for (i = 0; i<istr2; i++)
- // printf_s("%c", str12[i]);
- // else
- // for (istr1 = 0; istr1<nstr1; istr1++)
- // printf_s("%c", str1[istr1]);
- //
- // _getch();
- // return 0;
- //}
- //#include <conio.h>
- //#include <stdio.h>
- //#include <stdlib.h>
- //#include <time.h>
- //
- //struct date
- //{
- // int a;
- //};
- //struct list
- //{
- // struct date value;
- // struct list *next;
- // struct list *prev;
- //};
- //int main()
- //{
- // srand(time(NULL));
- // int i,n,m;
- // struct list *head, *last, *p1, *p2;
- // scanf_s("%d %d", &n,&m);
- // head = new struct list;
- // head->value.a = rand();
- // head->prev = NULL;
- // head->next = NULL;
- // p1 = head;
- // for (i = 2; i <= n; i++)
- // {
- // p1->next = new struct list;
- // p2 = p1->next;
- // p2->next = NULL;
- // p2->prev = p1;
- // p2->value.a = rand();
- // p1 = p2;
- //
- // }
- // last = p1;
- // for (p1 = head; p1->next != NULL;p1=p1->next)
- // {
- // printf_s("%d ", p1->value.a);
- // }
- // printf_s("%d ", p1->value.a);
- // printf_s("\n");
- // p1 = head;
- // for (i = 1; i < m ; i++)
- // p1 = p1->next;
- // p1->prev->next = p1->next;
- // p1->next->prev = p1->prev;
- // if (p1 == head)
- // {
- // head = p1->next;
- // head->prev = NULL;
- // }
- //
- // else if (p1 == last)
- // {
- // last = p1->prev;
- // last->next = NULL;
- // }
- // printf_s("%x %x \n", *p1->next, p1->prev);
- // free(p1);
- // for (p1 = head; p1->next != NULL; p1 = p1->next)
- // {
- // printf_s("%d ", p1->value.a);
- // }
- // printf_s("%d ", p1->value.a);
- // _getch();
- // return 0;
- //}
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- void f1 (char **s,int m[4])
- {
- char *s1;
- for (int j = 0; j < 4; j++)
- {
- for (int i = 0; i < m[j]; i++)
- {
- printf_s("%c", s[j][i]);
- }
- printf_s("\n");
- }
- }
- char* f3(char **s,int s11, int s22,int m[4])
- {
- char *strr;
- int j = 0;
- strr = new char[256];
- for (int i = 0; i < m[s11]; i++)
- {
- strr[j] = s[s11][i];
- j++;
- }
- for (int i = 0; i < m[s22]; i++)
- {
- strr[j] = s[s22][i];
- j++;
- }
- for (int i = 0; i < m[s11]+m[s22]; i++)
- {
- printf_s("%c", strr);
- }
- printf_s("\n");
- return strr;
- }
- int main()
- {
- system("chcp 1251");
- system("cls");
- int n[4], k;
- n[0] = 3;
- n[1] = 3;
- n[2] = 3;
- n[3] = 3;
- char *str[4];
- str[0] = new char[256];
- str[1] = new char[256];
- str[2] = new char[256];
- str[3] = new char[256];
- str[0] = "abc";
- str[1] = "def";
- str[2] = "ghi";
- str[3] = "klm";
- k = -1;
- for (; k != 0;)
- {
- printf_s("Если хотите выести строки на экран, нажмите 1 \n Если хотите удалить строку, нажмите 2 \n Если хотите соеденить 2 строки нажмите 3 \n Если хотете закончить работу нажмите 0 \n");
- scanf_s("%d", &k);
- if(k==1) f1(str, n);
- else if(k==2)
- {
- printf_s("Напишите номер строки которую хотите удалить:");
- for (int i = 0; i < 4; i++)
- if (n[i] != -1) printf_s("%d ", i);
- printf_s("\n");
- scanf_s("%d", &k);
- n[k] = -1;
- //free(str[k]);
- }
- else if (k == 3)
- {
- int s1, s2;
- printf_s("Введите номера строк которые хотите объеденить:");
- for (int i = 0; i < 4; i++)
- if (n[i] != -1) printf_s("%d ", i);
- printf_s("\n");
- scanf_s("%d %d",&s1,&s2);
- str[s1]=f3(str,s1,s2,n);
- //free(str[s2]);
- n[s2] = -1;
- }
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement