Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////lab4/////
- ////1
- using System;
- public class lab4_1
- {
- public static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- int sum = num % 10;
- while (num != 0)
- {
- Console.Write(num % 10 + " ");
- num = num / 10;
- if (num / 10 == 0)
- sum += num;
- }
- Console.Write("\nСумма цифр на первом и последнем месте = " + sum + "\n");
- }
- }
- ////2
- using System;
- public class lab4_2
- {
- public static bool IsPerfect(int n)
- {
- int sum = 0;
- for (int i = 1; i < n; i++)
- {
- if (n % i == 0)
- sum += i;
- }
- return sum == n;
- }
- public static void Main(string[] args)
- {
- Console.Write("a=");
- int a = int.Parse(Console.ReadLine());
- Console.Write("b=");
- int b = int.Parse(Console.ReadLine());
- for (int i = a; i <= b; i++)
- {
- if (IsPerfect(i))
- Console.WriteLine(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement