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
Программирование на ЯВУ, семинар 2
Search
Ilya
September 08, 2015
Education
0
72
Программирование на ЯВУ, семинар 2
Ilya
September 08, 2015
Tweet
Share
More Decks by Ilya
See All by Ilya
Программирование на ЯВУ, семинар 3
ilya
0
160
ОПК, семинар №8
ilya
0
54
ОПК, семинар №6
ilya
0
74
ОПК, семинар №4
ilya
0
110
ОПК, семинар №2
ilya
0
86
Other Decks in Education
See All in Education
2025年度春学期 統計学 第13回 不確かな測定の不確かさを測る ー 不偏分散とt分布 (2025. 7. 3)
akiraasano
PRO
0
120
データで見る赤ちゃんの成長
syuchimu
0
280
質のよいアウトプットをできるようになるために~「読む・聞く、まとめる、言葉にする」を読んで~
amarelo_n24
0
220
JPCERTから始まる草の根活動~セキュリティ文化醸成のためのアクション~
masakiokuda
0
220
フィードバックの伝え方、受け身のココロ / The Way of Feedback: Words and the Receiving Heart
spring_aki
1
140
相互コミュニケーションの難しさ
masakiokuda
0
220
Avoin jakaminen ja Creative Commons -lisenssit
matleenalaakso
0
2k
バックオフィス組織にも「チームトポロジー」の考えが使えるかもしれない!!
masakiokuda
0
130
Open Source Summit Japan 2025のボランティアをしませんか
kujiraitakahiro
0
850
Pydantic(AI)とJSONの詳細解説
mickey_kubo
0
190
Alumnote inc. Company Deck
yukinumata
0
2k
万博マニアックマップを支えるオープンデータとその裏側
barsaka2
0
820
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
53
7.8k
YesSQL, Process and Tooling at Scale
rocio
173
14k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Writing Fast Ruby
sferik
628
62k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
Done Done
chrislema
185
16k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
580
Raft: Consensus for Rubyists
vanstee
140
7.1k
Why Our Code Smells
bkeepers
PRO
339
57k
Transcript
http://en.cppreference.com/w/c http://learnxinyminutes.com/docs/c/ https://en.wikibooks.org/wiki/C_Programming http://c.learncodethehardway.org/book/ Kernigan and Ritchie: The C Programming
Language (K&R) Полезное про C
http://immersivemath.com/ila/index.html http://visualgo.net/ Полезное
void swap(double arr[]) { double x; x = arr[0]; arr[0]
= arr[1]; arr[1] = x; } void main() { double arr[2]; arr[0] = 1.0; arr[1] = 2.0; swap(arr); printf("%f %f\n", arr[0], arr[1]); } > 2.000000 1.000000 Массивы и функции
Нужно больше stdlib.h #include <math.h> printf("%f %2.f %.2f\n", M_PI, M_PI,
M_PI); > 3.141593 3 3.14 printf("%e %2.e %.2e\n", M_PI, M_PI, M_PI); > 3.141593e+00 3e+00 3.14e+00
#include <stdio.h> #include <stdlib.h> void main() { int i, number;
for(i = 0; i < 5; i++) { number = rand() % 100; printf("%d: %d\n", i, number); } } > 0: 83 > 1: 86 > 2: 77 > 3: 15 > 4: 93 Случайные числа
assert.h int factorial(int n) { // вырезано цензурой } void
main() { int i, result; for(i = 1; i < 6; i++) { result = factorial(i); printf("%d! = %d\n", i, result); } } > 1! = 1 > 2! = 2 > 3! = 6 > 4! = 24 > 5! = 120
printf("%d! = %d\n", -5, factorial(-5)); Segmentation fault (core dumped)
int factorial(int n) { assert(n >= 0); // вырезано цензурой
} printf("%d! = %d\n", -5, factorial(-5)); main: main.c:5: factorial: Assertion `n >= 0' failed. Aborted (core dumped)
Тестирование int celsius_to_fahrenheit(int c) { // } int fahrenheit_to_celsius(int f)
{ // } void main() { printf("%d\n", celsius_to_fahrenheit(30)); // 86 assert(celsius_to_fahrenheit(30) == 86); assert(fahrenheit_to_celsius(86) == 30); assert(celsius_to_fahrenheit(0) == 32); assert(fahrenheit_to_celsius(32) == 0); }
Стиль // Вычисление 2*X^2 + 3*X — 5 для X
int some_fun(int i) { int j=2,k,l=3,m,n=-5; if(i!=0) return j*i*i+l*i+n; else {printf("invalid x %d",i);} return -5; }
int polynomial(int x) { int a = 2, b =
3, c = -5; if(x == 0) { printf("Not a very interesting x\n"); return c; } else { return a * pow(x, 2) + b * pow(x, 1) + c; } }
Константы int i; int a[7]; // Ещё хуже, когда a[5]
for(i = 0; i < 6; i++) { a[i] = pow(10, i); printf("%d ", a[i]); } // Совсем плохо, когда так: for(i = 0; i < 6; i++) { ... for(i = 0; i < 6; i++) { ... for(i = 0; i < 6; i++) { ... for(i = 0; i < 6; i++) { ... for(i = 0; i < 6; i++) {
const unsigned size = 6; void main() { int i;
int a[size]; for(i = 0; i < size; i++) { a[i] = pow(10, i); printf("%d ", a[i]); } }