Upgrade to Pro — share decks privately, control downloads, hide ads and more …

第1回C++講習会 / intro-to-cpp-01

odanado
May 10, 2017
180

第1回C++講習会 / intro-to-cpp-01

odanado

May 10, 2017
Tweet

More Decks by odanado

Transcript

  1. C++ߨशձͷ೔ఔ ೔෇ ಺༰ උߟ 04/26 ঺հ&ೖग़ྗ 05/03 ٳΈ ݑ๏ه೦೔ 05/10

    ೖग़ྗͷ෮श ม਺,ԋࢉࢠ 05/17 ifͱfor PROGςετղઆ 05/24 ٳΈ(༧ఆ) PROGςετղઆ 05/31 ifͱforͷ෮श vector 06/07 set,map ୈ5ԋशࣨ 06/14 STLͷؔ਺ 06/21 ෮शίϯςετ 06/28 ະఆ 07/05 ະఆ 07/12 ະఆ 07/19 ະఆ 1
  2. C++ߨशձͷ಺༰ • جຊతʹਫ༵3ݶதʹऴΘΒͤΔ • 10෼෮श • 40෼࠲ֶ • 30෼ϛχίϯςετ •

    εϥΠυ΍ࢿྉ͸ωοτʹެ։͍ͯ͠·͢ • https://goo.gl/F0tgM5 • ཁ େֶΞΧ΢ϯτ • Θ͔Βͳ͍͜ͱ͕͋ͬͨΒ ͲΜͲΜ࣭໰ͯ͠Ͷ 2
  3. લճͷ෮श • λʔϛφϧͷ࢖͍ํ 4 $ mkdir kyopro $ cd kyopro

    $ mkdir lec01 $ cd lec01 $ code . ίϚϯυ໊ ҙຯ mkdir make directory σΟϨΫτϦ(ϑΥϧμ)Λ ৽ن࡞੒͢Δ cd change directory ݱࡏ͍ΔσΟϨΫτϦΛ มߋ͢Δ code Visual Studio Code Λ ىಈ͢Δ
  4. લճͷ෮श • Visual Studio Codeͷ࢖͍ํ • දࣔ(V) → ૯߹λʔϛφϧΛબ୒͢Δ •

    ίϯύΠϧ&ϓϩάϥϜͷ࣮ߦํ๏ 5 $ g++ -std=c++14 test.cpp $./a.out test.cpp ͸దٓࢦఆ͢Δ ϑΝΠϧΛม͑Δ
  5. ม਺ͷ֓೦ • ม਺ͱ͸ • ஋ΛهԱ͢ΔೖΕ෺ • هԱ͢Δ͚ͩͰͳ͘଍͠ࢉͱ͔ͷԋࢉ͕ग़དྷΔ 9 // a

    ͱ͍͏໊લͷೖΕ෺ʹ 10ͱ͍͏σʔλΛهԱ͢Δ int a = 10; // ࣮ࡍʹग़ྗ͢Δ cout << a << endl;
  6. ม਺ͷ֓೦ • ม਺ͱ͸ • ஋ΛهԱ͢ΔೖΕ෺ • هԱ͢Δ͚ͩͰͳ͘଍͠ࢉͱ͔ͷԋࢉ͕ग़དྷΔ 10 // a

    ʹ 10, b ʹ 20ΛهԱ͢Δ int a = 10; int b = 20; // c ʹ a ͱ b Λ଍ͨ݁͠ՌΛهԱ͢Δ int c = a + b; // 30 ͱग़ྗ͞ΕΔ cout << c << endl;
  7. ม਺ͷ֓೦ • ม਺ͷܕ • ܕʹΑͬͯهԱग़དྷΔσʔλͷछྨ͕ҟͳΔ 11 ܕ໊ int ੔਺ܕ 1,

    10, 20 string จࣈྻܕ ”hello world” double ࣮਺ܕ 3.14 bool ࿦ཧܕ true, false // ܕ໊ ม਺໊ = ஋; ͱॻ͘ int a = 10;
  8. ೖྗ 12 int a = 10; cout << a <<

    endl; 10 Ҏ֎ͷ஋Λग़ྗ͢Δʹ͸ϓϩάϥ ϜΛॻ͖׵͑Δඞཁ͕͋Δ ໰୊఺ ΩʔϘʔυ͔Βೖྗ int a; cin >> a; cout << a << endl;