docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: cpp-arrays-reallife
|
||||
title: "C++ Arrays Real-Life Examples"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["average calculation", "find minimum", "C++ 배열 실전 예제"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.83
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["cpp", "programming-language", "w3schools", "arrays", "real-life-example"]
|
||||
raw_sources: ["https://www.w3schools.com/cpp/cpp_arrays_reallife.asp"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CPP Arrays Real-Life Examples]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This example computes the array LENGTH via `sizeof(ages) / sizeof(ages[0])` but then iterates using the for-each loop (`for (int age : ages)`) — combining the sizeof-formula (needed for the average's DENOMINATOR) with the for-each style (used for the actual ITERATION) rather than picking one loop style exclusively, showing the two techniques from the Arrays Size chapter aren't mutually exclusive alternatives but tools combined based on what each specific line of code actually needs. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Average via accumulate-then-divide** — sum every element in a for-each loop, then divide by the `sizeof`-derived length. [S1]
|
||||
- **Find-minimum via self-seeded comparison** — initialize the tracking variable with the array's first element, then compare while looping through the rest (same technique as C). [S1]
|
||||
- **Mixing sizeof (for length) and for-each (for iteration)** — the two array techniques from earlier chapters combined in one program based on what each line needs. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Average calculation combining sizeof-length and for-each iteration: `int ages[8] = {20,22,18,35,48,26,87,70}; float avg, sum = 0; int length = sizeof(ages) / sizeof(ages[0]); for (int age : ages) { sum += age; } avg = sum / length;`. [S1]
|
||||
- Find-minimum via self-seeding: `int lowestAge = ages[0]; for (int age : ages) { if (lowestAge > age) { lowestAge = age; } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **sizeof 공식과 for-each 루프를 함께 사용**: 배열 길이 계산에는 sizeof 공식을, 실제 순회에는 for-each를 쓰는 조합이 두 기법이 상호 배타적 대안이 아니라 상황에 맞게 함께 쓰이는 도구임을 보여줌. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
나이 목록의 평균과 최솟값을 계산하는 두 예제가 원문에서 직접 실전 활용 사례로 제시되며, sizeof 기반 length 계산과 for-each 순회 패턴을 실제 통계 계산에 결합해 적용하는 방법을 보여준다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Combining sizeof (for length) and the for-each loop (for iteration) in one calculation (C++):
|
||||
```cpp
|
||||
int ages[8] = {20, 22, 18, 35, 48, 26, 87, 70};
|
||||
float avg, sum = 0;
|
||||
int length = sizeof(ages) / sizeof(ages[0]);
|
||||
for (int age : ages) {
|
||||
sum += age;
|
||||
}
|
||||
avg = sum / length;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C++ Tutorial]]
|
||||
- **관련 개념:** [[CPP Arrays Omit]], [[CPP Structs]], [[C Arrays RealLife]]
|
||||
- **참조 맥락:** 배열 섹션 마지막 — 구조체 및 열거형(Structs & Enum) 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C++ Arrays Real-Life Examples — https://www.w3schools.com/cpp/cpp_arrays_reallife.asp
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C++ Arrays Real-Life Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user