기억저장소

기억저장소

Programming Language/C++

[계절학기 C++] Array

roaminpixel 2014. 7. 9. 15:47
728x90

8.1  Arrays Hold Multiple Values

int tests[ISIZE];


8.2  Accessing Array Elements

tests[0] = 79;

cout << tests[0];

cin  >> tests[1];

tests[4] = tests[0] + tests[1];

cout << tests;


8.3  Inputting and Displaying Array Contents

const int ISIZE = 5;

int tests[ISIZE]; // Define 5-elt. array

cout << "Enter first test score ";

cin  >>  tests[0];


8.4  Array Initialization

const int ISIZE = 5;

int tests[ISIZE] = {79,82,91,77,84};


8.5  Processing Array Contents

if (principalAmt[3] >= 10000)

   interest = principalAmt[3] * intRate1;

 else

   interest = principalAmt[3] * intRate2;

tests[i]++;  // adds 1 to tests[i]

  tests[i++];  // increments i, but has

             // no effect on tests 


8.6  Using Parallel Arrays

const int ISIZE = 5;

string name[ISIZE];   // student name

float average[ISIZE]; // course average

char grade[ISIZE];    // course grade


8.7  The typedef Statement

typedef unsigned int Uint;

Uint tests[ISIZE];


8.8   Arrays as Function Arguments

       // Function prototype

     void showScores(int []); 

     // Function header

     void showScores(int tests[]) 

     // Function call

     showScores(tests);


8.9   Two-Dimensional Arrays

 int exams[4][3];


8.10 Arrays with Three or More Dimensions

void getRectSolid(short [][3][5]);


8.11 Vectors

scores.push_back(75);

howbig = scores.size();

scores.pop_back();

scores.clear();

while (!scores.empty()) 


8.12 Arrays of Class Objects

class Square

{ private:

    int side;

  public:

    Square(int s = 1)

    { side = s; }

    int getSide()

    { return side; }

};

Square shapes[10]; 



728x90
반응형

'Programming Language > C++' 카테고리의 다른 글

[C++] pipe 통신  (0) 2014.08.15
[계절학기 C++] Class  (0) 2014.07.09
[강좌#3] Expressions and Interactivity  (0) 2014.06.30
[강좌2] 3일차  (0) 2014.06.27
vector...  (0) 2013.07.10