Created
October 23, 2021 06:46
-
-
Save goish135/14855325b6186af2e8b577eab892690e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
/* | |
Out: num' | |
In: num | |
*/ | |
int main() | |
{ | |
int num; | |
cin >> num; | |
cout << num; | |
int digit; | |
int n1,n2,n3,n4; | |
int cnt=0; | |
while(...) // condition | |
{ | |
digit = num%10; // 1234%10=4 // 123%10=3 | |
cnt = cnt +1; | |
if(cnt==1) | |
{ | |
n4 = digit; | |
} | |
if(cnt==2) | |
{ | |
n3= digit; | |
} | |
if(...) | |
{ | |
... | |
} | |
if(...) | |
{ | |
... | |
} | |
num=num/10; // 1234/10=123 // 123/10 = 12 // 12/10 = 1 | |
} | |
cout << n1 << "-" << n2 << "-" << n3 << "-" << n4 << endl; // 1-2-3-4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment