2017.11.16李锦浩【第37天】
今天又根据书上的例子,打了一个关于结构链表的程序。另外,我今天温习了昨天所学的关于类的知识,还往下学习了构造和构析函数,大略知道了他们的用处。从今天开始我准备开始下载安卓studio以学习关于制作安卓APP的知识。
附:
//biaotou,h
#pragma once
#include<iostream>
using namespace std;
struct Node
{
int x;
int y;
Node*next;
};
void Input(Node*&head)
{
cout << "请按顺时钟方向输入四边形的个个点坐标";
Node*s, *p;
s = new Node;
p = new Node;
cout << "x=";
cin >> s->x;
cout << "y=";
cin >> s->y;
for (int n = 1; n <= 4; n++)
{
if (head == NULL)
{
head = s;
p = s;
head->next = p;
}
else
{
cout << "x=";
cin >> s->x;
cout << "y=";
cin >> s->y;
p->next = s;
p = s;
}
}
p->next = NULL;
delete s;
delete p;
}
void judge(Node*head)
{
int a[4][2];
for (int i = 0; i < 4; i++)
{
a[i][0]= head->x;
a[i][1]= head->y;
head = head->next;
}
if (a[0][0] == a[1][0] && a[2][0] == a[3][0])
if (a[0][1] == a[1][1] && a[2][1] == a[3][1])
cout << "正方形";
else
cout << "矩形";
if (a[0][1] == a[1][1] && a[2][1] == a[3][1])
if (a[0][0] == a[1][0] && a[2][0] == a[3][0])
cout << "正方形";
else
cout << "矩形";
else
cout << "其他四边形";
}
//YUAN.CPP
#include<iostream>
#include"标头.h"
using namespace std;
int main()
{
Node *head;
head = NULL;
Input(head);
judge(head);
system("pause");
return 0;
}
明日任务,继续学习类的知识和温习结构的知识。