diff options
Diffstat (limited to 'comp/work/8')
-rwxr-xr-x | comp/work/8/ascii | bin | 0 -> 18376 bytes | |||
-rwxr-xr-x | comp/work/8/ascii.c | 7 | ||||
-rwxr-xr-x | comp/work/8/ascii_word | bin | 0 -> 18568 bytes | |||
-rwxr-xr-x | comp/work/8/ascii_word.c | 11 | ||||
-rwxr-xr-x | comp/work/8/parity | bin | 0 -> 18376 bytes | |||
-rwxr-xr-x | comp/work/8/parity.c | 34 |
6 files changed, 52 insertions, 0 deletions
diff --git a/comp/work/8/ascii b/comp/work/8/ascii Binary files differnew file mode 100755 index 0000000..8260b96 --- /dev/null +++ b/comp/work/8/ascii diff --git a/comp/work/8/ascii.c b/comp/work/8/ascii.c new file mode 100755 index 0000000..751c1b9 --- /dev/null +++ b/comp/work/8/ascii.c @@ -0,0 +1,7 @@ +#include<stdio.h> + +int main(){ + int c; + scanf("%c", &c); + printf("%d\n", c); +} diff --git a/comp/work/8/ascii_word b/comp/work/8/ascii_word Binary files differnew file mode 100755 index 0000000..3ede671 --- /dev/null +++ b/comp/work/8/ascii_word diff --git a/comp/work/8/ascii_word.c b/comp/work/8/ascii_word.c new file mode 100755 index 0000000..ba9fa95 --- /dev/null +++ b/comp/work/8/ascii_word.c @@ -0,0 +1,11 @@ +#include<stdio.h> +#include<string.h> +int main(){ + char sentence[1000]; + + fgets(sentence, 1000, stdin); + for (int i = 0; i < strlen(sentence) - 1; i++){ + printf("%d \0 ", (int)sentence[i]); + } + printf("\n"); +} diff --git a/comp/work/8/parity b/comp/work/8/parity Binary files differnew file mode 100755 index 0000000..66738ce --- /dev/null +++ b/comp/work/8/parity diff --git a/comp/work/8/parity.c b/comp/work/8/parity.c new file mode 100755 index 0000000..a87d07a --- /dev/null +++ b/comp/work/8/parity.c @@ -0,0 +1,34 @@ +#include<stdio.h> +#include<string.h> +#include<stdlib.h> + +int main(){ + char num[8]; + int parity; + scanf("%s", num); + char number[8]; + for (int i = 0; i < 8; i++){ + if (i == 7){ + if (num[i] == '1'){ + parity = 1; + }else{ + parity = 0; + } + }else{ + if (num[i] == '1'){ + number[i] = 1; + }else{ + number[i] = 0; + } + } + } + int number_of_ones = 0; + for (int i = 0; i < 8; i++){ + if (number[i] == 1){ + number_of_ones++; + } + } + if (number_of_ones % 2 == parity){ + printf("bad\n"); + } +} |