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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ilya
March 12, 2015
Education
56
0
Share
ОПК, семинар №8
Указатели на функции
Ilya
March 12, 2015
More Decks by Ilya
See All by Ilya
Программирование на ЯВУ, семинар 3
ilya
0
170
Программирование на ЯВУ, семинар 2
ilya
0
74
ОПК, семинар №6
ilya
0
77
ОПК, семинар №4
ilya
0
110
ОПК, семинар №2
ilya
0
89
Other Decks in Education
See All in Education
What workforce agencies must have in place to compete for and deliver on RESTART grants
territorium
PRO
0
150
Liberalism's Last Man and Asia
vyadav
0
120
✅ レポート採点基準 / How Your Reports Are Assessed
yasslab
PRO
0
340
事業紹介資料(トレーナー養成講座)
kentaro1981
0
280
LinkedIn
matleenalaakso
0
4.1k
0513
cbtlibrary
0
140
教育現場から見た Ruby on Rails
yasslab
PRO
0
140
モブ社員がモブエンジニアを名乗って得られたこと_20260413
masakiokuda
4
480
Measuring what matters
jonoalderson
0
300
We部コミュニティスライド2026-04-24
junhat6
0
160
Modelamiento Matematico (Ingresantes UNI 2026)
robintux
0
280
Data Management and Analytics Specialisation
signer
PRO
0
1.8k
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
The Spectacular Lies of Maps
axbom
PRO
1
740
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
510
Unsuck your backbone
ammeep
672
58k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
280
4 Signs Your Business is Dying
shpigford
187
22k
The untapped power of vector embeddings
frankvandijk
2
1.7k
Producing Creativity
orderedlist
PRO
348
40k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
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);