Advertisement
bestTamken

find armstrong

Jun 28th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System.IO;
  2. using System;
  3. using System.Math;
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         Console.WriteLine("Hello, World!");
  9.         int n, temp, dem=0, i, sum;
  10.         Console.WriteLine("Nhap so N: ");
  11.         n = int.Parse(Console.ReadLine());
  12.         temp=n;
  13.         while(temp>0)
  14.         {
  15.             temp=temp/10;
  16.             dem++;
  17.         }
  18.         while(n>0)
  19.         {
  20.             i=n%10;
  21.             n=n/10;
  22.             sum=sum+pow(i,dem);
  23.         }
  24.         if(sum==n)
  25.         Console.WrileLine("{0} la so Armstrong",n);
  26.         else
  27.         Console.WrileLine("{0} khong la so Armstrong",n);
  28.         Console.ReadKey;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement