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 and Interaction Design - Lecture 2 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.4k
Adobe Express
matleenalaakso
1
8k
とある長岡高専卒のおっさんがIT企業のマネージャーになるまで / journey-from-nagaoka-kosen-grad-to-it-manager
masaru_b_cl
0
140
Técnicas y Tecnología para la Investigación Neurocientífica en el Neuromanagement
jvpcubias
0
170
生成AIとの付き合い方 / Generative AI and us
kaityo256
PRO
11
2k
Library Prefects 2025-2026
cbtlibrary
0
120
バケットポリシーの記述を誤りマネコンからS3バケットを操作できなくなりそうになった話
amarelo_n24
1
120
[Segah 2025] Gamified Interventions for Composting Behavior in the Workplace
ezefranca
0
220
Editor First: Customizing TYPO3 for a Cleaner Workflow
ulli
0
110
いわゆる「ふつう」のキャリアを歩んだ人の割合(若者向け)
hysmrk
0
130
Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
2.6k
Web Architectures - Lecture 2 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
140
7.2k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
Bash Introduction
62gerente
615
210k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Speed Design
sergeychernyshev
32
1.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
A better future with KSS
kneath
239
18k
How STYLIGHT went responsive
nonsquared
100
5.9k
Documentation Writing (for coders)
carmenintech
75
5.1k
YesSQL, Process and Tooling at Scale
rocio
174
15k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
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);