49 lines
852 B
C
49 lines
852 B
C
void printf(char*, ...);
|
|
|
|
int fibonacci(int n) {
|
|
if (n < 2)
|
|
return 1;
|
|
return fibonacci(n - 1) + fibonacci(n - 2);
|
|
}
|
|
|
|
void change_first(char otus[5]) {
|
|
otus[0] = 115;
|
|
}
|
|
|
|
|
|
struct Otus;
|
|
|
|
struct Otus {
|
|
int field;
|
|
};
|
|
void update(struct Otus potus) {
|
|
potus.field = 20;
|
|
}
|
|
|
|
void update_ptr(char* ptr) {
|
|
*ptr = 50;
|
|
}
|
|
|
|
int main() {
|
|
char text[30] = "10th fibonacci number is %d!\n";
|
|
printf(text, fibonacci(10));
|
|
|
|
char somelist[5] = { 1, 2, 3, 4, 5 };
|
|
char* somelist_ptr = somelist;
|
|
|
|
change_first(somelist);
|
|
|
|
printf("first element: %d!\n", somelist[0]);
|
|
printf("first element via ptr: %d!\n", somelist_ptr[0]);
|
|
|
|
struct Otus otus = { 5 };
|
|
update(otus);
|
|
|
|
printf("first field: %d!\n", otus.field);
|
|
|
|
char hello = 10;
|
|
update_ptr(&hello);
|
|
printf("hello: %d!\n", hello);
|
|
|
|
return 0;
|
|
} |