Browse Source

Add first exercises of chapter 06

master
T. Meissner 9 years ago
parent
commit
7046a29fc4
5 changed files with 82 additions and 0 deletions
  1. +21
    -0
      c_primer_plus/chapter06/01.c
  2. +16
    -0
      c_primer_plus/chapter06/02.c
  3. +16
    -0
      c_primer_plus/chapter06/03.c
  4. +19
    -0
      c_primer_plus/chapter06/04.c
  5. +10
    -0
      c_primer_plus/chapter06/Makefile

+ 21
- 0
c_primer_plus/chapter06/01.c View File

@ -0,0 +1,21 @@
#include <stdio.h>
int main(void) {
unsigned char abc [26];
for (size_t i = 'a'; i <= 'z'; i++) {
abc[i - 'a'] = i;
}
for (size_t i = 0; i < sizeof(abc); i++) {
printf("%c", abc[i]);
}
printf("\n");
return 0;
}

+ 16
- 0
c_primer_plus/chapter06/02.c View File

@ -0,0 +1,16 @@
#include <stdio.h>
int main(void) {
for (size_t i = 0; i < 5; i++) {
for (size_t j = 0; j <= i; j++) {
printf("$");
}
printf("\n");
}
return 0;
}

+ 16
- 0
c_primer_plus/chapter06/03.c View File

@ -0,0 +1,16 @@
#include <stdio.h>
int main(void) {
for (int i = 0; i < 6; i++) {
for (int j = 'F'; j >= ('F'-i); j--) {
printf("%c", j);
}
printf("\n");
}
return 0;
}

+ 19
- 0
c_primer_plus/chapter06/04.c View File

@ -0,0 +1,19 @@
#include <stdio.h>
int main(void) {
unsigned char letter = 'A';
for (unsigned char i = 0; i < 6; i++) {
for (unsigned char j = letter; j <= (letter + i); j++) {
printf("%c", j);
}
letter += (i + 1);
printf("\n");
}
return 0;
}

+ 10
- 0
c_primer_plus/chapter06/Makefile View File

@ -0,0 +1,10 @@
SRC := $(shell ls *.c)
%: %.c
gcc -Wall -Wextra $@.c -o $@
.PHONY: clean
clean:
@rm -f ??

Loading…
Cancel
Save