Replace all ‘0’ with ‘5’ in an input Integer without using arrays for individual digits
@AdiChat i m doing this
#include<iostream.h> int main() { int n; cin>>n; while(num!= 0) { a = num%10; num=num/10; If(!a) { num = num10 + 5; } else { num = num10 + a; } return 0; }
where should i place the pull request
I am totally new to this hackathon, I didn't know where to answer that's why I commented.
On 5 Oct 2017 10:11 p.m., "abhishek kumar" [email protected] wrote:
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
int a = 1;
while( n / a >= 1){
a = a* 10;
int temp = n % a - n % (a / 10);
temp = temp / (a/10);
int temp2;
if(temp == 0){
temp2 = 5 * (a/ 10); n = n - temp + temp2;}
}
cout << n << endl;
}
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OpenGenus/cosmos/issues/603#issuecomment-334522936, or mute the thread https://github.com/notifications/unsubscribe-auth/AOcJm_nQ9HjslUCA8a2svTRpVgHQiDY5ks5spQbSgaJpZM4PvUq9 .
This should go to the unclassified section 👍
Integer input_int = 1001; String str = input_int.toString(); str = str.replace('0', '5'); Integer output_integer = Integer.valueOf(str);