Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Node
- {
- class Program
- {
- public static int NameCounter(Node<string> head, string name)
- {
- int counter = 0;
- int counter1 = 0;
- int counter2 = 0;
- Node<string> cheak = head;
- int length = name.Length;
- while (cheak.HasNext() != false)
- {
- counter = counter + 1;
- }
- counter = counter + 1;
- cheak = head;
- for (int i = 0; i < counter; i++)
- {
- for (int j = 0; j < length; j++)
- {
- if (cheak.GetValue()[j] == name[j])
- {
- counter1 = counter1++;
- }
- if (counter1 == length)
- {
- counter2 = counter2++;
- }
- }
- cheak = cheak.GetNext();
- }
- return counter2;
- }
- public static Node<String> Targil19()
- {
- Node<string> head = null;
- Console.WriteLine("enter name ");
- string n = Console.ReadLine();
- Node<string> head1 = new Node<string>(n);
- head = head1;
- while (head1.GetValue() != "end")
- {
- head1.SetNext(head);
- head = head1;
- string n1 = Console.ReadLine();
- head1 = new Node<string>(n1);
- }
- return head;
- }
- public static Node<string> Targil20(Node<string> head)
- {
- Node<string> p = head;
- head = reserve(head);
- p.SetNext(null);
- return head;
- }
- public static Node<string> reserve(Node<string> head)
- {
- Node<string> p = head, q, w;
- if (!p.HasNext())
- {
- return (head);
- }
- q = p.GetNext();
- while (q.HasNext())
- {
- w = q.GetNext();
- q.SetNext(p);
- p = q;
- q = w;
- }
- q.SetNext(p);
- return q;
- }
- public static Node<int> SumNode(int num)
- {
- int mod = num % 10;
- int newNum = num / 10;
- Node<int> head = new Node<int>(0);
- Node<int> s2 = new Node<int>(mod);
- head.SetNext(s2);
- int sum = mod;
- while (newNum != 0)
- {
- mod = newNum % 10;
- sum = sum + mod;
- Node<int> s1 = new Node<int>(sum);
- Node<int> cheak = head;
- while (cheak.HasNext())
- {
- cheak = cheak.GetNext();
- }
- cheak.SetNext(s1);
- newNum = newNum / 10;
- }
- return head;
- }
- public static bool IFISMecahlek(Node<int> head, int n)
- {
- if (n < 10)
- {
- if (head.GetValue() % n == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- Node<int> cheak = head;
- Node<int> before = head;
- int counter10 = 10;
- if (cheak.HasNext())
- {
- cheak = cheak.GetNext();
- }
- else
- {
- return false;
- }
- int num = before.GetValue();
- num = num + ((cheak.GetValue() - before.GetValue()) * counter10);
- if (cheak.HasNext())
- {
- cheak = cheak.GetNext();
- before = before.GetNext();
- }
- counter10 = counter10 * 10;
- while (cheak.HasNext())
- {
- num = num + ((cheak.GetValue() - before.GetValue()) * counter10);
- cheak = cheak.GetNext();
- before = before.GetNext();
- counter10 = counter10 * 10;
- }
- num = num + ((cheak.GetValue() - before.GetValue()) * counter10);
- if (num % n == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- public static int sum(Node<int> head, int counter10, int n)
- {
- Node<int> cheak = head;
- Node<int> p = head;
- if (cheak.HasNext())
- {
- cheak = cheak.GetNext();
- n = (cheak.GetValue() - p.GetValue()) * counter10 + n;
- }
- else
- {
- n = (cheak.GetValue() - p.GetValue()) * counter10 + n;
- return n;
- }
- return sum(cheak, counter10 * 10, n);
- }
- static void Main(string[] args)
- {
- Console.WriteLine("adar good luck!");
- Node<string> headNames = new Node<string>("popo Gamliel");
- Node<string> head1 = new Node<string>("lolo Yatskan");
- Node<string> head2 = new Node<string>("polo Club");
- Node<string> head3 = new Node<string>("lopo Teranovsky");
- headNames.SetNext(head1);
- head1.SetNext(head2);
- head2.SetNext(head3);
- Console.WriteLine(headNames);
- //int targil18 = NameCounter(headNames, "popo");
- Console.WriteLine("5");
- //Console.WriteLine(targil18);
- headNames = Targil20(headNames);
- Console.WriteLine(headNames);
- Console.WriteLine(SumNode(123456));
- Console.WriteLine(IFISMecahlek(SumNode(123456), 123456));
- Console.WriteLine(sum(SumNode(123456), 1, 0));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement