Skip to content
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
77 changes: 77 additions & 0 deletions level1/p01_runningLetter/作业1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include<stdio.h>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不能使用中文文件名

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ojbk

#include<windows.h>
#include<stdlib.h>
#define boundary 50;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多了分号

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

。。。ok

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多了分号;
这个文件能编译通过吗?
所有代码要求,只有 编译通过&&运行正确 后才能提交;
如果遇到了难以解决的问题,可以在QQ群中贴出代码或错误信息,请大家帮忙分析,胆子大、脸皮厚是我学东西的方式哈

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

突然发现两个一样的文件?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

....可能push的姿势不对


void setCursor(int x, int y)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码能编译过吗?
必须编译通过,且执行正确后才能提交;
如果过程中遇到的问题,难以解决,可以在qq群中把错误信息或代码贴出来,大家帮你分析

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

。。。。。还真的过了


Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种空行应该删掉

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉多余的空行;只有是代码看起来更清晰的空行才是“好”空行,空格同理

{
HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(hCon,pos);

}



void setConsole()

{

HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);

SMALL_RECT rc;

rc.Left = 0;

rc.Top = 0;

rc.Right = boundary;

rc.Bottom = 29;

SetConsoleWindowInfo(hCon, TRUE, &rc);

}



void run()

{

setConsole();
int x =0, y = 0;
int test = 1;
char value;
scanf("%c", &value);
setCursor(x, y);
printf("%c", value);
Sleep(70);
while (1) {
system("cls");
if (test)/*换boundary蜜汁显示缺小括号*/
setCursor(x++, y);
else
setCursor(--x, y);
if (x >= 50)
test = !test;
else if(x<0)
test = !test;

printf("%c", value);
Sleep(70);
}
}



int main() {

run();
system("pause");
return 0;

}
23 changes: 23 additions & 0 deletions level1/p02_isPrime/作业2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main() {

int a, i, m;
scanf("%d", &a);
m = sqrt((double)a);
for (i = 2; i <= m; i++)
if (a%m == 0)
break;
else if (i <= m)
printf("No!this is not a prime.");
else
printf("Yes,it is a prime.");



system("pause");
return 0;

}

16 changes: 16 additions & 0 deletions level1/p03_Diophantus/作业3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <stdio.h>
#include<stdlib.h>
void main()
{
int i;
for (i = 1;i<300; i++)
{
if (i*1.0 / 6 + i*1.0 / 12 + i*1.0/ 7+ 5 + 4 == i*1.0/ 2)
{
printf("����ͼ��������%d��", i);
break;
}
}
system("pause");
return 0;
}
21 changes: 21 additions & 0 deletions level1/p04_ narcissus/作业4.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include<stdio.h>
#include<math.h>
int main() {

int a, b, c,value;

printf("����������");

for (int i = 2; i < =1000; i++) {
a = sqrt(i);
if (i%a!= 0) {
printf("%d\n", i);
}

}



system("pause");
return 0;
}
Empty file added level1/p05_allPrimes/作业5.c
Empty file.
22 changes: 22 additions & 0 deletions level1/p06_Goldbach/text6.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<stdio.h>
int prime(int n)
{
for (int i = 2; i*i <= n; i++) //�����
if (n%i == 0)return 0;
return n > 1;
}
int main()
{
int x, i;
printf("������1~100������:");
scanf("%d", &x); //���������
for (i = 2; i <= x / 2; i++) //�����ظ�
if (prime(i) && prime(x - i))
{
printf("%d=%d+%d\n", x, x - i, i);
getchar();
return 0;

}

}
105 changes: 105 additions & 0 deletions level1/p07_encrypt_decrypt/TEXT(7).c
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include<stdio.h>
#include<string.h>
#include<string.h>
int main() {

int i, j, k, num, num1;
char a1[30], a2[30];
printf("��ѡ������:\n1.����\t 2.����\n");
scanf("%d", &num);
if (num = 1) {

printf("����������ı�:");
int num1 = 0;
int len;
scanf("%d",&a1);
len = strlen(a1);
printf("�����ƶ�λ��:");
scanf("%d", num1);
for (i = 0; i < len; i++) {
if (a1[i] >= 'A'&&a1[i] <= 'Z')
{
a1[i] = (a1[i] - 'A' + num1) % 26 + 'A';
}
else if (a1[i] >= 'a'&&a1[i] <= 'z')
{
a1[i] = (a1[i] - 'a' + num1) % 26 + 'a';
}

}
printf("������ܽ��:%c", a1);
printf("\n");
}
if (num = 2) {
printf("����������ı�:");
int len,num1;
scanf("%d", &a1);
len = strlen(a1);
for (num1 = 0; num1 < 26;num1++) {
for (i = 0; i < len; i++) {
if (a1[i] >= 'A'&&a1[i] <= 'Z')
{
a1[i] = (a1[i] - 'A' + num1) % 26 + 'A';
}
else if (a1[i] >= 'a'&&a1[i] <= 'z')
{
a1[i] = (a1[i] - 'a' + num1) % 26 + 'a';
}

}
printf("������ܽ��:%c",a1);
system("pause");
printf("\n");

}
}
getchar();
return 0;
}

#define MAX 30
/*int main() {
char P[MAX] = { 0 };
printf("������������ı�:");
scanf("%d", &P);
int len, i, j, k, temp,num = 0;
len = strlen(P);
int A1[1][MAX] = { 0 }, A2[1][MAX] = { 0 };
int t1[MAX] = { 0 }, t2[MAX] = { 0 };
printf("�������ܳ�:\n");
for (i = 0; i < len; i++) {
for (j = 0; j < len; j++) {
scanf("%d", &A1[i][j]);
printf("�ܳ�Ϊ:%s", A1);
}
}

printf("��ѡ������:\n1.����\t 2.����\n");
scanf("%d", &num);
if (num = 1) {
for (i = 0; i < len; i++) {
if (P[i] >= 'A'&&P[i] <= 'Z') {
P[i] = P[i] +32;
t1[i] = P[i] - 'a';
}
}
for (i = 0; i < len; i++) {
for (j = 0; j < len; j++) {
temp = 0;
for (k = 0; k < len; k++) {
temp+= t1[k] * A1[k][j];
}
A2[i][j] = temp;
printf("%d\t", A2[i][j]);
}
printf("%d\n");
}
printf("%d", A2);
for (i = 0; i < len; i++) {
t2[i] = A2[i] + 'a';
}
printf("���ܽ��Ϊ:%d", t2[i]);
system("pause");
}
return 0;
}*/ //emmmmm��debug
19 changes: 19 additions & 0 deletions level1/p08_hanoi/text8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<stdio.h>
void hano(int n,char p1, char p2, char p3) {
if (n == 1) {
printf("\t%c-->%c", p1, p3);
}
else
{
hano(n - 1, p1, p3, p2);
printf("\t%c-->%c\n", p1, p3);
hano(n - 1, p2, p1, p3);
}
}
int main() {
int n;
printf("�����ƶ�����:");
scanf("%d", &n);
hano(n, 'p1', 'p2','p3');
return 0;
}
48 changes: 48 additions & 0 deletions level1/p11_linkedList/Unfinish2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include<stdio.h>
#include<malloc.h>
int* ptr = NULL;
static int count = 0;
void insert(data){
if (ptr == NULL) {
ptr = (int*)malloc(sizeof(int));
ptr[0] = data;
}
else {
ptr = (int*)realloc(ptr, sizeof(int)*(count + 1));
ptr[count] = data;
}
count++;
}
void show() {
int i = 0;
for (i = 0; i < count; i++) {
printf("%d\n", ptr[i]);
}
}
int main(int argc, char*argv[]) {
int c = 0;
int data;
while (1)
{
printf("choice");
printf("1 is to insert data\n");
printf("2 is to show data.\n");
printf("3 is to quit\n ");
scanf("%d\n", &c);
switch (c) {
case 1:
printf("date=");
scanf("%d\n", &data);
insert(data);
break;
case 2:
show();
break;
case 3:
exit(0);
}
}
return 0;
getchar();
}
//����2��emmm����
Loading