Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ОПК, семинар №8
Search
Ilya
March 12, 2015
Education
0
55
ОПК, семинар №8
Указатели на функции
Ilya
March 12, 2015
Tweet
Share
More Decks by Ilya
See All by Ilya
Программирование на ЯВУ, семинар 3
ilya
0
160
Программирование на ЯВУ, семинар 2
ilya
0
73
ОПК, семинар №6
ilya
0
75
ОПК, семинар №4
ilya
0
110
ОПК, семинар №2
ilya
0
88
Other Decks in Education
See All in Education
HCI Research Methods - Lecture 7 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.3k
Sanapilvet opetuksessa
matleenalaakso
0
34k
2025年度伊藤正彦ゼミ紹介
imash
0
150
俺と地方勉強会 - KomeKaigi・地方勉強会への期待 -
pharaohkj
1
1.6k
Measuring your measuring
jonoalderson
0
230
Surviving the surfaceless web
jonoalderson
0
230
Design Guidelines and Models - Lecture 5 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.2k
1008
cbtlibrary
0
120
コマンドラインを見直そう(1995年からタイムリープ)
sapi_kawahara
0
630
1014
cbtlibrary
0
510
MySmartSTEAM 2526
cbtlibrary
0
170
国際卓越研究大学計画|Science Tokyo(東京科学大学)
sciencetokyo
PRO
0
42k
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
1
210
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Designing for Performance
lara
610
70k
Highjacked: Video Game Concept Design
rkendrick25
PRO
0
260
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
130
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
280
End of SEO as We Know It (SMX Advanced Version)
ipullrank
2
3.8k
Building AI with AI
inesmontani
PRO
1
590
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
120
Transcript
Указатели на функции
#include <stdio.h> #include <stdlib.h> double long_calculation(double x, unsigned n) {
double result = 1.0; unsigned i; for(i = 0; i < n; i++) { result *= x; sleep(1); } return result; } int main() { double my_power = long_calculation(2.0, 5); printf("Result: %lf\n", my_power); return 0; }
Callbacks void printer(int i) { printf("Progress: %d%% complete\n", i); }
int main() { void (*printer_func)(int); printer_func = &printer; printer_func(20); return 0; }
double long_calculation(double x, unsigned n, void (*callback)(int)) { double result
= 1.0; unsigned i, progress; for(i = 0; i < n; i++) { result *= x; progress = (unsigned) (((double) i)/ n * 100); callback(progress); sleep(1); } return result; }
typedef void (*callback_func)(int); double long_calculation(double x, unsigned n, callback_func callback);
int main() { callback printer_func = &printer; double my_power = long_calculation(2.0, 3, printer_func); printf("Result: %lf\n", my_power); return 0; }
void bubble_sort(int *base, size_t size) { int temp; size_t i,
j; for(i = 0; i < size; i++) { for(j = i; j < size; j++) { if(base[i] > base[j]) { temp = base[i]; base[i] = base[j]; base[j] = temp; } } } } Абстракция
int main() { int array[] = {1, 9, 5, 4,
7, 2, 4, 6}; size_t length = sizeof(array)/sizeof(int); bubble_sort(array, length); size_t i; for(i = 0; i < length; i++) { printf("%d ", array[i]); } printf("\n"); return 0; }
void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *,
const void *)); int greater_than(const void* pleft, const void* pright) { int left = *(int*) pleft; int right = *(int*) pright; return left > right; } qsort(array, length, sizeof(int), greater_than);
int less_than(const void* pleft, const void* pright) { int left
= *(int*) pleft; int right = *(int*) pright; return left < right; } qsort(array, length, sizeof(int), less_than);
void (*signal(int, void(*)(int)))(int); Ужасы языка С
typedef void (*signal_handler)(int signum); void (*signal(int, void(*)(int)))(int); signal_handler signal(int signum,
signal_handler handler);