U E D R , A S I H C RSS

스네이크바이트/C++

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;
	}
}

1.2.


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');
}


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:16
Processing time 0.0123 sec