Commit f5511b11 authored by xingqiao's avatar xingqiao
Browse files

helloworld basic code files

parent d1e99a18
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
if (argc > 2) {
......@@ -7,7 +8,28 @@ int main(int argc, char **argv) {
}
int parity = 0;
int number = 0;
for (int i = 0; i < argc; i++) {
char *arg = argv[i];
if (i == 1) {
size_t len = strlen(arg);
for (int j = 0; j < len; j++) {
int a = arg[j];
while (a != 1) {
if (a % 2 == 1) {
number += 1;
a -= 1;
}
a /= 2;
}
number += 1;
}
}
}
if (number % 2 == 1) {
parity = 1;
}
printf("%d\n", parity);
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment