URI Online Judge qus no 2176 Parity solution
#include <stdio.h>
#include <string.h>
int main()
{
char str[150]; // str is a array
int i, cnt=0;
scanf("%s", str); // for string %s
for(i=0; str[i]; i++)
if(str[i]=='1')
cnt++; //cnt increment
if(cnt%2 == 0)
str[i] = '0';
else
str[i] = '1';
str[i+1] = '\0';
printf("%s\n", str);
return 0;
}
Read on-> বেডরুম সাজানোর ডেকোরেশন আইডিয়া - Bedroom Decoration
0 comments:
Post a Comment