Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Flipping a bit
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { string Input="10110101101"; char []inp=new char[Input.Length]; int i=0; foreach(char x in Input) { inp[i]=x; i++; } Console.WriteLine(inp); int inpt=3,inpt2=4; int counter=0; for(int j=1;j<=inp.Length;j++) { if(j%inpt==0) { // Console.WriteLine(inp[j]); char flipvalue='0'; if(inp[j]=='0') flipvalue='1'; Console.WriteLine(flipvalue); inp[j]=flipvalue; counter++; } if(j%inpt2==0) { // Console.WriteLine(inp[j]); char flipvalue='0'; if(inp[j]=='0') flipvalue='1'; Console.WriteLine(flipvalue); inp[j]=flipvalue; counter++; } if(j%inpt2==0 && j%inpt==0) counter++; } Console.WriteLine(inp); Console.WriteLine(counter); } } }
run
|
edit
|
history
|
help
0
Armstrong
GFV SDXZASX
enum.TryParse
adxcsaxsd
sdsadxaxsd
Math 9.6
Testing 001
4.3 Static typing: benefits, drawbacks and ways to minimise them
Raiz Cuadrada
MyGenerics