Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

康祥瑞 2021080902028 #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 8 additions & 52 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,52 +1,8 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
*
!*/
!*.cpp
!*.c
!*.h
!*.hpp
.vs/
x64/
14 changes: 14 additions & 0 deletions c语言作业-kxr/Diophantus/源.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include<stdio.h>
#include<stdlib.h>

int main(){
float i;
for (i = 0; i < 1000; i++) {
if ((i / 12 + i / 6 + i / 7 + 5 + i / 2 + 4) == i) {
printf("\nage=%.0f", i);
break;
}
}
return 0;
system("pause");
}
28 changes: 28 additions & 0 deletions c语言作业-kxr/allPrime/allPrime/源.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<stdio.h>
#include<windows.h>
int main() {
int number, k = 1, ret = 0;
puts("�������ޣ�");
scanf_s("%d", &number);
system("cls");
printf(" 2��%6d��������\n", number);
printf("������������������������������������������������������\n");
printf("��");
for (int j = 2; j < number; ++j) {

for (int i = 2; i < j; ++i) {
if (j % i == 0)ret++;
}
if (ret == 0) {
printf("%6d", j);
if (k % 8 == 0) {
printf(" ��\n��");
}
k++;
}
ret = 0;
}
printf("\n������������������������������������������������������\n");
system("pause");
return 0;
}
24 changes: 24 additions & 0 deletions c语言作业-kxr/encrypt and decrypt/源.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include<stdio.h>
#include<stdlib.h>

int main() {
char code[10],password[10];
gets_s(code);
for (int i = 0; i < 10; i++) {
if (code[i] != 'z')
code[i] += 1;
else if (code[i] == 'z')
code[i] = 'a';
}
printf("%s", code);
system("pause");
gets_s(password);
for (int j = 0; j < 10; j++) {
if (password[j] != 'a')
password[j] -= 1;
else if (password[j] == 'a')password[j] = 'z';
}
printf("%s", password);
system("pause");
return 0;
}
35 changes: 35 additions & 0 deletions c语言作业-kxr/goldbach/源.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int a, b = 0, flag = 0,prime[100],z=1;
for (a = 2; a <= 100; a++) {
flag = 0;
for (b = 2; b < a-1; b++) {
if (a % b == 0) {
flag = 1;
break;
}
}
if (flag == 0) {
prime[z] = a;
z++;
}
}//��������
int number,i=0;
printf("����һ��186���ڵ�ż��\n");
scanf_s("%d", &number);
for (int e = 1; e <= 100; e++) {
for (int f = 1; f <= e; f++) {
if (number == prime[f] + prime[e]) {
printf("%d=%d+%d\n", number, prime[e], prime[f]);
i = 1;
}
}
}//�ж�
if (i == 0)printf("���Dz���ʶ186���ڵ�ż������զ�Σ�\n");//error����
system("pause");
return 0;
}
28 changes: 28 additions & 0 deletions c语言作业-kxr/hanoi1/源.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<stdio.h>
#include<stdlib.h>
void move(int x, int y)
{
printf("%c->%c\n", x, y);
}
void hanoi(int n, char a, char b, char c)
{
if (n == 1)
{
move(a, c);
}
else
{
hanoi(n - 1, a, c, b);
move(a, c);
hanoi(n - 1, b, a, c);
}
}
int main()
{
int n = 0;
printf("�����������\n");
scanf_s("%d", &n);
hanoi(n, 'A', 'B', 'C');
system("pause");
return 0;
}
13 changes: 13 additions & 0 deletions c语言作业-kxr/isPrime/isPrime/源.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include<stdio.h>

int main() {
int number,ret=0;
puts("����һ����������");
scanf_s("%d", &number);
for (int i = 2; i < number; ++i) {
if (number % i == 0)ret++;
}
if (ret != 0)printf("%d������\n", number);
else printf("%d����\n", number);
return 0;
}
83 changes: 83 additions & 0 deletions c语言作业-kxr/linkedlist/linkedlist/源.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include<stdio.h>
#include<stdlib.h>
typedef struct Node {
int data;
struct Node* next;
}Node;
int i = 0,mid=1;
//��������
void createLink(Node* head, int size) {
Node* rear = head;
int i;
for (i = 0; i < size; ++i) {
Node* newnode = (Node*)malloc(sizeof(Node));
newnode->next = NULL;
scanf_s("%d", &newnode->data);
rear->next = newnode;
rear = newnode;
}
}
//��������
void travelLink(Node* head) {
Node* p = head->next;
while (p != NULL) {
printf("%d\t", p->data);
p = p->next;
}
putchar('\n');
}
//��ת����
void reverseLink(Node* head) {
Node* curr;
Node* pre = NULL;
while (head->next != NULL) {
curr = head->next;
head->next = curr->next;
curr->next = pre;
pre = curr;
}
head->next = pre;
}
//�ڸ������в��ҵ�һ��ֵΪ 5 �Ľڵ㣬����ҵ��򷵻ظýڵ����ţ����򷵻أ�1
int findfirst5(Node* head) {
Node* p = head;
while (p->next != NULL) {
if (p->data == 5) return i;
p = p->next;
i++;
}
return -1;
}
//������һ��ֵΪ 5 �Ľڵ㣬����ֵͬ��
int findother5(Node* head) {
int m;
m = mid;
Node* p = head;
while (p->next != NULL) {
if (p->data == 5) {
if (m == 0) {
mid++;
return i-1;
}
else if (m != 0)m--;
}
p = p->next;
i++;
}
return -1;
}
int main() {
Node* head = (Node*)malloc(sizeof(Node));
head->next = NULL;
int r,s;
createLink(head, 10);//��������
travelLink(head);//��������
reverseLink(head);//��ת����Ԫ��
travelLink(head);//��������
r = findfirst5(head);//�ڸ������в��ҵ�һ��ֵΪ 5 �Ľڵ㣬����ҵ��򷵻ظýڵ����ţ����򷵻أ�1
printf("��1��5�ڵ�%1dλ\n", r);
s = findother5(head);//������һ��ֵΪ 5 �Ľڵ㣬����ֵͬ��
printf("��%d��5�ڵ�%1dλ\n",mid,s);
return 0;
}

84 changes: 84 additions & 0 deletions c语言作业-kxr/maze/源.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<Windows.h>

int main() {
int ch,x=3,y=8,x_=0;
char map[50][50] = {
" *****#***",
" ** ** *",
" ** **** *",
" *o *** *",
" ** * **",
" **** * **",
" *** **",
" *********",
};
printf("**************************************************\n");
printf("********* ��ӭ����ȫ����˵��Թ� *************\n");
printf("******* ��wasd�ƶ���o������#������ͨ�� *********\n");
printf("**************************************************\n");
Sleep(2000);
system("cls");
printf("**************************************************\n");
printf("********* ������������ɿ�ʼ��Ϸ *********\n");
printf("**************************************************\n");
system("pause");
system("cls");
for (int i = 0; i < 17; i++)
puts(map[i]);
while(x!=0||y!=12) {
ch = _getch();
if (ch == 's') {
x_ = x + 1;
if (map[x_][y] != '*') {
map[x][y] = ' ';
x = x_;
map[x][y] = 'o';
system("cls");
for (int i = 0; i < 17; i++)
puts(map[i]);
}
}
else if (ch == 'a') {
x_ = y - 1;
if (map[x][x_] != '*') {
map[x][y] = ' ';
y = x_;
map[x][y] = 'o';
system("cls");
for (int i = 0; i < 17; i++)
puts(map[i]);
}
}
else if (ch == 'w') {
x_ = x - 1;
if (map[x_][y] != '*') {
map[x][y] = ' ';
x = x_;
map[x][y] = 'o';
system("cls");
for (int i = 0; i < 17; i++)
puts(map[i]);
}
}
else if (ch == 'd') {
x_ = y + 1;
if (map[x][x_] != '*') {
map[x][y] = ' ';
y = x_;
map[x][y] = 'o';
system("cls");
for (int i = 0; i < 17; i++)
puts(map[i]);
}
}
}
system("cls");
printf("**************************************************\n");
printf("**** ��ϲ��ͨ���ˣ� ****\n");
printf("**************************************************\n");
system("pause");
return 0;
}
Loading