From 8ee6537d8c0eb1782793a6b214237371939173f8 Mon Sep 17 00:00:00 2001 From: p3nqlbfe7 <785875121@qq.com> Date: Fri, 15 Mar 2024 14:34:35 +0800 Subject: [PATCH 1/5] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0319c63 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# gitProject + -- 2.34.1 From e95745dd9ea049fa5ee6f3f079f2e978c76103bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E5=90=8D=E7=80=9A?= <785875121@qq.com> Date: Sat, 16 Mar 2024 18:08:32 +0800 Subject: [PATCH 2/5] add dir --- gitProject | 1 + 1 file changed, 1 insertion(+) create mode 160000 gitProject diff --git a/gitProject b/gitProject new file mode 160000 index 0000000..8ee6537 --- /dev/null +++ b/gitProject @@ -0,0 +1 @@ +Subproject commit 8ee6537d8c0eb1782793a6b214237371939173f8 -- 2.34.1 From 4ccbee0469e3ea5926e8c462f1c655fa417d0786 Mon Sep 17 00:00:00 2001 From: pwvl263yg <1902278070@qq.com> Date: Tue, 19 Mar 2024 22:41:59 +0800 Subject: [PATCH 3/5] ADD file via upload --- 练习及笔记.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 练习及笔记.cpp diff --git a/练习及笔记.cpp b/练习及笔记.cpp new file mode 100644 index 0000000..6646755 --- /dev/null +++ b/练习及笔记.cpp @@ -0,0 +1,40 @@ +#include +#include +using namespace std; +int add(int a,int b) +{ + int sum=0; + if(a+3<=b) + sum++; + if(a-3>=1) + sum++; + return sum+1; +} +int cdd(int a,int b) +{ + int sum=0; + if(a+3<=b) + sum--; + if(a-3>=1) + sum--; + return sum-1; +} +int main() +{ + int m,q,op,num,sum=0; + cin>>m>>q; + for(int i=0;i>op>>num; + if(op==1) + { + sum+=add(num,m); + } + if(op==2) + { + sum+=cdd(num,m); + } + cout< Date: Tue, 19 Mar 2024 22:42:41 +0800 Subject: [PATCH 4/5] =?UTF-8?q?Delete=20'=E7=BB=83=E4=B9=A0=E5=8F=8A?= =?UTF-8?q?=E7=AC=94=E8=AE=B0.cpp'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 练习及笔记.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 练习及笔记.cpp diff --git a/练习及笔记.cpp b/练习及笔记.cpp deleted file mode 100644 index 6646755..0000000 --- a/练习及笔记.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -using namespace std; -int add(int a,int b) -{ - int sum=0; - if(a+3<=b) - sum++; - if(a-3>=1) - sum++; - return sum+1; -} -int cdd(int a,int b) -{ - int sum=0; - if(a+3<=b) - sum--; - if(a-3>=1) - sum--; - return sum-1; -} -int main() -{ - int m,q,op,num,sum=0; - cin>>m>>q; - for(int i=0;i>op>>num; - if(op==1) - { - sum+=add(num,m); - } - if(op==2) - { - sum+=cdd(num,m); - } - cout< Date: Tue, 19 Mar 2024 22:43:14 +0800 Subject: [PATCH 5/5] ADD file via upload --- 舞伴问题 栈.cpp | 122 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 舞伴问题 栈.cpp diff --git a/舞伴问题 栈.cpp b/舞伴问题 栈.cpp new file mode 100644 index 0000000..415ab01 --- /dev/null +++ b/舞伴问题 栈.cpp @@ -0,0 +1,122 @@ +#include +#include + +typedef struct { + char name[20]; + char sex; +} DataType; + +struct Node { + DataType data; + struct Node* next; +}; +typedef struct Node *PNode; +struct Queue +{ + PNode f; + PNode r; +}; +typedef struct Queue *LinkQueue; +LinkQueue SetNullQueue_Link() +{ + LinkQueue lqueue; + lqueue = (LinkQueue)malloc(sizeof(struct Queue)); + if (lqueue != NULL) + { + lqueue->f = NULL; + lqueue->r = NULL; + } + else + printf("Alloc failure! \n"); + return lqueue; +} + +int IsNullQueue_link(LinkQueue lqueue) +{ + return (lqueue->f == NULL); +} + +void EnQueue_link(LinkQueue lqueue, DataType x) +{ + PNode p; + p = (PNode)malloc(sizeof(struct Node)); + if (p == NULL) + printf("Alloc failure!"); + else { + p->data = x; + p->next = NULL; + if (lqueue->f == NULL) + { + lqueue->f = p; + lqueue->r = p; + } + else + { + lqueue->r->next = p; + lqueue->r = p; + } + } +} +void DeQueue_link(LinkQueue lqueue) +{ + struct Node * p; + if (lqueue->f == NULL) + printf("It is empty queue!\n "); + else + { + p = lqueue->f; + lqueue->f = lqueue->f->next; + free(p); + } +} +DataType FrontQueue_link(LinkQueue lqueue) +{ + if (lqueue->f == NULL) + { + printf("It is empty queue!\n"); + } + else + return (lqueue->f->data); +} + +void DancePartner(DataType dancer[], int num) +{ + LinkQueue Queue_head = SetNullQueue_Link(); + + for (int i = 0; i < num; i++) + { + + if (!IsNullQueue_link(Queue_head) && + (FrontQueue_link(Queue_head).sex) != dancer[i].sex) + { + if (dancer[i].sex == 'F') + printf("%s %s\n", dancer[i].name, Queue_head->f->data.name); + else + { + printf("%s %s\n", Queue_head->f->data.name, dancer[i].name); + } + DeQueue_link(Queue_head); + } + else + { + EnQueue_link(Queue_head, dancer[i]); + } + } + printf("\n"); + + if (!IsNullQueue_link(Queue_head)) + { + printf("%s", Queue_head->f->data.name); + } +} + + + +int main() +{ + DataType dancer[9]; + for (int i = 0; i < 9; i++) + scanf("%s %c", dancer[i].name, &dancer[i].sex); + DancePartner(dancer, 9); + return 0; +} -- 2.34.1