#include<bits/stdc++.h> using namespace std; void shift(vector<int> &arr,int element){ int count=0; for(int i=0;i<arr.size();i++){ if(arr[i]!=element){ arr[count++]=arr[i]; } } int i=0; while(count<arr.size()){ arr[count++]=element; } } void printSequence(){ int prev=1; int mult=1; for(int i=0;i<7;i++){ mult*=2; int nextprev= prev+mult; cout<<nextprev<<" "; prev=nextprev; } } int size(int n){ int count=0; while(n%10!=0){ count++; n/=10; } return count; } bool armstrong(int n){ int size1=size(n); int temp=n,rem=0,sum=0; while(n!=0){ rem=n%10; sum+=pow(rem,size1); n/=10; } cout<<endl; cout<<sum; return sum==temp; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter