MFC공부를 기 강경 C++과 객 대 내 명기 만든 다.
1. 래 ¶
~cpp
#include<iostream>
using namespace std;
class student
{
private:
char Name[20]; //
int ID; //
int Math; //
int Korean; //국
int English; //
public:
student(); //디
student(char *name, int id, int math, int kor, int eng);//
~student(); //멸
int getTotal(); // 구는
void outputID(); //, 력
int getMath(); // 근
int getKor(); //국 근
int getEng(); // 근
};
student::student()
{
}
student::student(char *name, int id, int math, int kor, int eng)
{
strcpy(Name, name); //기()
ID = id; //기
Math = math; //기
Korean= kor; //국기
English = eng; //기
}
student::~student()
{
}
int student::getTotal()
{
return Math + Korean + English;//리
}
void student::outputID()
{
cout << ID << " " << Name << endl;//과 력
}
int student::getMath()
{
return Math; //리
}
int student::getKor()
{
return Korean; //국리
}
int student::getEng()
{
return English; //리
}
void main()
{
int Max;
int bestStu;
int i;
const int numberOfStudent = 10;//
student stu[numberOfStudent] =
{student("KangHeeKyoung", 953, 99, 99, 99),
student("KimSooJin", 954, 55, 100, 12),
student("ParkJinHa", 955, 66, 87, 11),
student("ParkJinYoung", 956, 11, 23, 54),
student("KimTaeHyuk", 957, 10, 9, 4),
student("LeeChunSoo", 958, 100, 40, 19),
student("AnJaeHyun", 959, 0, 0, 0),
student("ByunJoonWon", 960, 2, 3, 1),
student("SinJaeDong", 961, 1, 2, 100),
student("NoSooMin", 963, 0, 4, 1)};//객 배 및 기
Max = 0;
for(i = 0; i < numberOfStudent; i++)
{
if(stu[i].getTotal() > Max)
{
bestStu = i;
Max = stu[i].getTotal();
}
} //대값과 대값 가 객를 는다.
cout << ": ";
stu[bestStu].outputID(); //, 력
Max = 0;
for(i = 0; i < numberOfStudent; i++)
{
if(stu[i].getMath() > Max)
{
bestStu = i;
Max = stu[i].getMath();
}
}
cout << ": ";
stu[bestStu].outputID();
Max = 0;
for(i = 0; i < numberOfStudent; i++)
{
if(stu[i].getKor() > Max)
{
bestStu = i;
Max = stu[i].getKor();
}
}
cout << "국: ";
stu[bestStu].outputID();
Max = 0;
for(i = 0; i < numberOfStudent; i++)
{
if(stu[i].getEng() > Max)
{
bestStu = i;
Max = stu[i].getEng();
}
}
cout << ": ";
stu[bestStu].outputID();
}
1.1. ¶
~cpp
#include<iostream.h>
void output(int a);
void main()
{
const int b = 10;
output(5);
b--;
cout << b <<endl;
}
void output(int a)
{
for(int i = 0; i < a; i++)
{
cout << "" << endl;
}
}
2. ¶
~cpp
#include<iostream.h>
void main()
{
char c;
char *pc = &c;
c = 'y';
cout << *pc << endl;
cout << c << endl;
}
배
~cpp
#include<iostream.h>
void main()
{
char array[3];
char *pa;
pa = array; //&array[0]
*pa = 'a';
*(pa + 1) = 'b';
*(pa + 2) = 'c';
for(int i = 0; i < 3; i++)
cout << array[i] << endl;
}
++
~cpp
#include<iostream.h>
void main()
{
char array[3];
char *pa;
pa = array; //&array[0]
for(int i = 65; i < 68; i++)
*(pa++) = i;
for(i = 0; i < 3; i++)
cout << *(--pa) << endl;
}
배
~cpp
#include<iostream.h>
void main()
{
char array[3];
char *pa[3];
//pa = array; //&array[0]
for(int i = 0; i < 3; i++)
pa[i] = &array[i];
for(i = 0; i < 3; i++)
*pa[i] = i+65;
for(i = 0; i < 3; i++)
cout << array[i] << endl;
}
구
~cpp
#include<iostream.h>
struct node
{
char data;
node *link;
};
void main()
{
node type1;
type1.data = 'a';
node type2;
type2.data = 'b';
type1.link = &type2;
type2.link = NULL;
cout << (*(type1.link)).data << endl;
}
링드 리
~cpp
#include<iostream>
using namespace std;
struct Node
{
char data;
Node* link;
};
void main()
{
Node array[100];
Node* pNode;
int index = 0;
char input;
do{
cout << ": ";
cin >> input;
if(input != 'q')
{
if(index == 0){
array[0].data = input;
array[0].link = NULL;
}
else
{
array[index].data = input;
array[index].link = NULL;
array[index-1].link = &array[index];
}
index++;
pNode = array;
while(pNode != NULL)
{
cout << pNode->data << " ";
pNode = pNode->link;
}
cout << "NULL" << endl;
}
}while(input != 'q');
}










