Skip to content

Instantly share code, notes, and snippets.

@agluszak
Created April 5, 2017 19:08
Show Gist options
  • Save agluszak/674e74518bccb8da0ea3b0c6e0597331 to your computer and use it in GitHub Desktop.
Save agluszak/674e74518bccb8da0ea3b0c6e0597331 to your computer and use it in GitHub Desktop.
//Wypisz rezultat działania poniższych
//fragmentów programów:
//2.1
#include<stdio.h>
int Licz(int a);
int a = 4;
void main(void) {
auto int a, b = 3;
a = Licz(b);
while (a)
printf("%d %d;", Licz(--a), a--);
}
int Licz(int b) {
static int a;
return (a += --b);
}
//2.2
void main(void) {
float t[5] = {1,2,3,4,5};
float *w = t;
int i = t[0]--;
t[t[1]] = t[1] / 2;
++t[i++];
t[i] = t[--t[i + t[i]]];
for (i = 0; i < 5; i++) {
int i = 4;
printf("%d %d,"
i--, *w++);
}
}
//2.3
#include<stdio.h>
#define MAX(a, b)((a < b) ? b : a)
void main() {
int a = 10, b = 5;
int c = MAX(a++, b++);
printf("%d %d %d", a, b, c);
}
//2.4
#include<stdio.h>
main() {
int t[5] = {1,2,3,4,5};
int *w = t;
for (int i = 0, i<5, i++) {
switch (*w++) {
case 0:
(*w) += 5;
case 1:
++*w = i;
case 2:
i = ++*w;
default:
i += ++(*w);
break;
}
}
printf("%d %d", i, *w);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment