Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
/////////////// struct Student { int ege; struct Student* NEXT; }; ///////////////////////////////////////// struct Student* init(int nEge) { struct Student *p = (struct Student*)malloc(sizeof(struct Student)); p-> ege = nEge; p->NEXT = 0; return p; } ////////////////////////////////////////// void add(struct Student** h, int nEge) { struct Student* novy = (struct Student*)malloc(sizeof(struct Student)); novy->ege = nEge; novy->NEXT = *h; *h = novy; } /////////////////////////////////////////////// void addend(struct Student **h, int nEge) { struct Student* novy = (struct Student*)malloc(sizeof(struct Student)); struct Student* curr = *h; while (curr->NEXT != NULL) { curr = curr->NEXT; } novy-> ege = nEge; novy->NEXT = NULL; curr->NEXT = novy; } ////////////////////////////////////////////// int delln(struct Student** h, int m) { struct Student* novy = (struct Student*)malloc(sizeof(struct Student)); struct Student* curr = *h; if (m == 0) { *h = curr->NEXT; free(curr) ; return 0 ; } for (int i = 1; i < m; i ++) { curr = curr->NEXT; } novy = curr->NEXT; curr->NEXT = novy ->NEXT; free(novy) ; novy = curr->NEXT; } ////////////////////////////////////////////////// int addn(struct Student **h, int m, int nege) { struct Student *novy = *h; struct Student *nov = (struct Student*)malloc(sizeof(struct Student)); struct Student *curr = *h; if(m == 0) { add(h, nege); return 0 ; } for(int i = 1; i < m; i ++) { if(curr->NEXT == NULL) { addend(h, nege); return 0; } curr = curr->NEXT; } novy = curr->NEXT; nov -> ege = nege; curr->NEXT = nov; nov ->NEXT = novy; } ///////////////////////////////////////// void show(struct Student *h) { struct Student* p = h; while(p) { printf("%d ", p->ege); p = p->NEXT; } } ///////////////////////////////////////////// void ja_svoboden(struct Student *h) { struct Student *p = h; while(p) { p = p->NEXT; free(h); h = p; } } ///////////////////////////////////////////// int main() // { struct Student *head; int n, m, nege; scanf("%d", &n); // Кол-во элементов в списко if(n == 0) { scanf("%d%d", &m, &nege); head = init(nege); show( head); return 0; } scanf("%d", &m); head = init( m); for(int i = 1; i < n; i++) { scanf("%d" , &m); addend(&head, m); } scanf("%d%d", &m, &nege); addn(&head, m, nege); show(head); ja_svoboden(head); return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)