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
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
89
Other Decks in Education
See All in Education
HyRead2526
cbtlibrary
0
200
Padlet opetuksessa
matleenalaakso
10
15k
1021
cbtlibrary
0
400
Chapitre_2_-_Partie_3.pdf
bernhardsvt
0
150
AWS re_Invent に全力で参加したくて筋トレを頑張っている話
amarelo_n24
2
120
LotusScript でエージェント情報を出力してみた
harunakano
0
120
HCI Research Methods - Lecture 7 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.3k
核軍備撤廃に向けた次の大きな一歩─核兵器を先には使わないと核保有国が約束すること
hide2kano
0
240
0203
cbtlibrary
0
110
外国籍エンジニアの挑戦・新卒半年後、気づきと成長の物語
hypebeans
0
730
AIで日本はどう進化する? 〜キミが生きる2035年の地図〜
behomazn
0
110
2025年の本当に大事なAI動向まとめ
frievea
0
170
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
1
210
It's Worth the Effort
3n
188
29k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
220
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.2k
Mind Mapping
helmedeiros
PRO
0
86
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Practical Orchestrator
shlominoach
191
11k
How STYLIGHT went responsive
nonsquared
100
6k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
730
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
200
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
69
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);