78 lines
1020 B
C++
78 lines
1020 B
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
int Iz1;
|
|
|
|
struct Node {
|
|
int data;
|
|
struct Node* next;
|
|
};
|
|
|
|
|
|
struct Node* first = NULL;
|
|
|
|
void printList() {
|
|
struct Node* ptr = first;
|
|
while (ptr != NULL) {
|
|
printf("(%d) -> ", ptr->data);
|
|
ptr = ptr->next;
|
|
}
|
|
printf("NULL\n");
|
|
}
|
|
|
|
void addToHead(int value) {
|
|
struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
|
|
|
|
newNode->next = first;
|
|
newNode->data = value;
|
|
|
|
first = newNode;
|
|
}
|
|
|
|
void elLeftIx10(int value) {
|
|
struct Node* ptr = first;
|
|
int i = 0;
|
|
while (ptr != NULL) {
|
|
if (i < value) {
|
|
ptr->data *= 10;
|
|
}
|
|
ptr = ptr->next;
|
|
i++;
|
|
}
|
|
}
|
|
|
|
void clearList() {
|
|
while (first != NULL)
|
|
{
|
|
struct Node* delNode = first;
|
|
first = first->next;
|
|
free(delNode);
|
|
}
|
|
}
|
|
|
|
|
|
void main() {
|
|
first = NULL;
|
|
printList();
|
|
|
|
addToHead(1);
|
|
addToHead(3);
|
|
addToHead(8);
|
|
printList();
|
|
|
|
printf("-------------------------------------------\n");
|
|
|
|
elLeftIx10(1);
|
|
printList();
|
|
|
|
elLeftIx10(2);
|
|
printList();
|
|
|
|
clearList();
|
|
printList();
|
|
|
|
|
|
}
|