avan ado em c
Usando Algoritmos e Estruturas de Dados
Fundamentais
✒ ✓ ✔ ✕
✖ ✗ ✘✙ ✚ ✛✙
✜ ✙
✢ ✘ ✣✤ ✙ ✣✥ ✗
The Ualg Informatics Lab
Universidade do Algarve http://w3.ualg.pt/~jvo jvo@ualg.pt
✦ ✧ ★ ✩ ✪ ✫
✬ ✯
✵ ✩✶ ✧
✶★ ✱ ✷ ✱ ✸✹ ✫
✧ ✩✶ ✺
✸✻✼ ✧ ✲ ✼ ✻✱ ✽ ✫
❂ ✫ ✿
✧ ★ ✼ ✻✱ ✸❅✦ ✧ ✽ ✱ ✽ ✱
✽ ✧ ✩✶ ✱
✸ ✻ ✼ ✧ ✲ ❁ ✱ ❑ ❃ ✻ ✩ ✻✶ ✧
✼ ✱ ★✶ ✱
❏ ✱ ★ ✱
❚ ❯ ✬ ✳ ❋ ❑ ❆
❂ ★ ✧ ✱ ✶ ✻❃ ✧
❄
✱
❂ ★ ✻✱ ❁ ✪ ✫
✩ ✫ ✷
✽ ✧
✾ ✿
✱
✫ ✲ ✩ ❑
✰ ✱ ✲ ✭ ✳ ✴
❀ ✻✼ ✧ ✲ ❁ ✱
❂ ★ ✧ ✱ ✶ ✻❃ ✧
❈ ✷ ★ ✱ ✩ ❉ ✧ ★ ✻❃ ✱ ✽ ✱ ✩
✹ ✶ ✶ ❏ ▲▼ ▼ ✼ ★ ✧ ✱ ✶ ✻ ❃ ✧ ✼ ✫ ✿ ✿
❂ ✫ ✿ ✿
✬ ✭ ✬ ✮
✬ ❖ ✬
❊ ✭❋
❂ ✫ ✿ ✿
✫ ✲ ✩ ❄ ✶ ★ ✻✷ ✾ ✻ ❁ ✪ ✫ ❅❆
● ✫ ★✶✾ ❍ ✱ ✸ ✭ ● ✱ ★ ✱
❃ ✧ ★
✾ ✿
✫ ✲ ✩ ✭✫ ★ ❍ ▼ ✸ ✻ ✼ ✧ ✲ ✩ ✧ ✩ ▼ ✷ ◆ ❅ ✲ ✼ ❅ ✲ ✽ ▼ ❊ ✭❋ ▼ ❏ ✶ ▼
✧ ✼ ✫ ✲ ✽
✶ ★ ✧ ✧ ✶ ❑ ✾ ✻✶ ✧
◗ ✳ ✳ ❑ ✱ ✲
✫ ✾
✱
✩ ✫
❇
✼ ■ ❏ ✻✱
✧ ✲ ❃ ✻✧
✾ ✿
✱
❘ ★ ✱ ✲ ✼ ✻✩ ✼ ✫ ❑ ❂ ✱ ✸✻❙ ✫ ★ ✲ ✻✱
✭
✁ ✁ ✂ ✄☎ ☎ ✆ ✝ ✞ ✟ ✠ ✡ ☛ ✞ ✂ ✁ ☎ ☞ ✌ ✍ ✎
✪ ✫ ❅
✏ ☎ ✝ ✝ ✑
Índice
0. Preâmbulo
✁ ✂✄ ✂
☎ ✆ ✝ ✞✟✠ ✡
☛ ✞☞ ✡
✁ ✂✌ ✂
✍ ✡ ✎ ☛ ✏ ✑ ✡
✒ ✓ ☛ ✔ ☛
✁ ✂✕ ✂
☎ ✖ ✗ ✟✘ ☛
✙ ✚ ✝
✁ ✂✛ ✂
✜ ✗ ✢ ☛ ✔ ✚ ✠ ✟✣ ✚ ✘ ✎ ✡ ✓
1. Introdução
✄ ✂✄ ✂
✍ ✡ ✏ ✑ ✡
✔ ✚
✎ ✟✤ ✡
✔ ✚
✔ ☛ ✔ ✡ ✓
✄ ✂✌ ✂
✥ ✟✤ ✡ ✓
✤ ✢ ✟ ✣ ✟✎ ✟☞ ✡ ✓
✥ ✟✤ ✡ ✓
✔ ✚ ✦ ✟✘ ✟✔ ✡ ✓
✄ ✂✕ ✂
✤ ✚ ✞✡
✒ ✎ ✟✞✟✧ ☛ ✔ ✡ ✢
✄ ✂✕ ✂ ✄ ✂
★ ✓ ✎ ✢ ✒ ✎ ✒ ✢ ☛ ✓
✄ ✂✕ ✂✌ ✂
✩ ✘ ✟✪ ✚ ✓
✄ ✂✛ ✂
✍ ✡ ✏ ✑ ✡
✔ ✚
✚ ✓ ✎ ✢ ✒ ✎ ✒ ✢ ☛
✔ ✚
✔ ☛ ✔ ✡ ✓
✄ ✂✫ ✂
★ ✬ ✚ ✢ ✠ ✭✠ ✟✡ ✓
2. Arrays e Ponteiros
✌ ✂✄ ✂
☎ ✡ ✘ ✎ ✚ ✟✢ ✡ ✓
✌ ✂✌ ✂
✮ ✤ ✚ ✢ ☛ ✏ ✪ ✚ ✓
✠ ✡ ✣
✤ ✡ ✘ ✎ ✚ ✟✢ ✡ ✓
✌ ✂✕ ✂
✯ ✎ ✢ ✟✘ ✗ ✓
✌ ✂✛ ✂
☎ ✡ ✘ ✎ ✚ ✟✢ ✡ ✓
✤ ☛ ✢ ☛
✠ ✡ ✘ ✓ ✎ ☛ ✘ ✎ ✚ ✓
☎ ✡ ✘ ✎ ✚ ✟✢ ✡ ✓
✠ ✡ ✘ ✓ ✎ ☛ ✘ ✎ ✚ ✓
☎ ✡ ✘ ✎ ✚ ✟✢ ✡ ✓
✠ ✡ ✘ ✓ ✎ ☛ ✘ ✎ ✚ ✓
☎ ✡ ✘ ✎ ✚ ✟✢ ✡ ✓
✤ ☛ ✢ ☛
✦ ✒ ✘ ✏ ✪ ✚ ✓
☎ ✡ ✘ ✎ ✚ ✟✢ ✡ ✓
✤ ☛ ✢ ☛
✚ ✓ ✎ ✢ ✒ ✎ ✒ ✢ ☛ ✓
✌ ✂✫ ✂
✌ ✂✰ ✂
✤ ☛ ✢ ☛
✠ ✡ ✘ ✓ ✎ ☛ ✘ ✎ ✚ ✓
✌ ✂✱ ✂
✌ ✂✲ ✂
✁ ✁ ✂ ✄☎ ☎ ✆ ✝ ✞ ✟ ✠ ✡ ☛ ✞ ✂ ✁ ☎ ☞ ✌ ✍ ✎
☎ ✝ ✝ ✑
✌ ✂
✂
✜ ✢ ✢ ☛
✁ ✓ ✔ ✚ ✤ ✡ ✘ ✎✚ ✟✢ ✡ ✓
✌ ✂✄ ✁ ✂
✜ ✢ ✗ ✒ ✣ ✚ ✘ ✎ ✡ ✓
✔ ☛
✦ ✒ ✘ ✏ ✑ ✡
✣ ☛ ✟✘
✌ ✂✄ ✄ ✂
★ ✬ ✚ ✢ ✠ ✭✠ ✟✡ ✓
3. Reserva dinâmica de memória
✕ ✂✄ ✂
✂ ✚ ✓✚ ✢☞ ☛
✔ ✟✘
✄ ✣