Skip to content

Instantly share code, notes, and snippets.

@goish135
Created October 23, 2021 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goish135/14855325b6186af2e8b577eab892690e to your computer and use it in GitHub Desktop.
Save goish135/14855325b6186af2e8b577eab892690e to your computer and use it in GitHub Desktop.
#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