I mean, it's not that I have not been trying to solve the given exercise (number-sequences) myself - then I have posted my results where I can see what the code does different than what I want it to do, posted some follow up questions and did not hear back.
I just do not want to jump right away to your exercise while the first one is not done yet.
Anyways, thanks for the hint in regards to style and codeblocks...
btw., lol - I somehow managed to finish the very original exercise (printing out an X-sign - mentioned it in my first post), but the code looks terrible and it feels that the learning-effect was low, since it feels that I have missed core strategies there:
Code:
#include <stdio.h>#include <stdlib.h>
int main() {
int z, s, leer_li, leer_re, n;
printf("Please enter the number of rows: ");
scanf("%d", &n);
if (n % 2 != 0) {
for (z = 1; z <= n/2; z++) {
printf("%*s", z - 1, "");
printf("*");
for (s = 1; s <=1; s++) {
printf("%*s" , n - 2*z, "");
printf("*\n");
}
}
printf("%*s", z - 1, "");
printf("*\n");
for (z = n/2; z >= 1; z--) {
printf("%*s", z - 1, "");
printf("*");
for (s = 1; s <=1; s++) {
printf("%*s" , n - 2*z, "");
printf("*\n");
}
}
} else {
for (z = 1; z < n/2; z++) {
for (leer_li = 1; leer_li <= 1; leer_li++) {
printf("%*s", z - 1, "");
printf("*");
}
for (leer_re = 1; leer_re <= 1; leer_re++) {
printf("%*s", n - 2*z, "");
printf("*\n");
}
}
for (leer_li = 1; leer_li <= 2; leer_li++) {
printf("%*s", z - 1, "");
printf("**\n");
}
for (leer_li = n/2 - 2; leer_li >= 0; leer_li--) {
printf("%*s", leer_li, "");
printf("*");
for (leer_re = 1; leer_re <= 1; leer_re++) {
printf("%*s", (n - 2) - 2 * leer_li, "");
printf("*\n");
}
}
}
return 0;
}
It somehow works, but feels still off.
Would still like to know how this one works (in dependence of a number-variable n) :
"Make this output the sequence
0 5
1 3
2 1
3 0
2 1
1 3
0 5
"
I feel that being able to put out this sequence would have currently a large learning impact.
After that, I might wanna try your exercise, but need to reread and try to understand it and/or get familiar with spreadsheets at first...