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

实在抱歉做晚了。。。 #73

Open
wants to merge 5 commits into
base: master
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
Binary file added a.out
Binary file not shown.
19 changes: 19 additions & 0 deletions level1/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/wine/msvcrt",
"/usr/include/c++/8.2.1/tr1",
"/usr/include/wine/windows"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
29 changes: 29 additions & 0 deletions level1/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
7 changes: 7 additions & 0 deletions level1/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.associations": {
"*.c": "c",
"stdlib.h": "c",
"ai.h": "c"
}
}
22 changes: 22 additions & 0 deletions level1/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"tasks": [
{
"type": "shell",
"label": "gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
]
}
],
"version": "2.0.0"
}
Binary file added level1/a.out
Binary file not shown.
Binary file added level1/p01_runningLetter/running_letter_linux
Binary file not shown.
72 changes: 72 additions & 0 deletions level1/p01_runningLetter/running_letter_linux.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <termios.h>
#include <stdlib.h>
#include <string.h>

int main()

{
//通过函数loctl();获得终端界面的参数
//定义winsize结构体变量
struct winsize size;
//tiocswinsz命令取到此结构的新值
ioctl(STDIN_FILENO,TIOCGWINSZ,&size);
printf("%d\n" ,size.ws_col);
printf("%d\n" ,size.ws_row);

//查了一堆后,我理解了Linux上难点在哪里(笑)
//我仰天大呼:要一个计时器!
//室友说
//不,你需要睡眠
//(这是一个双关笑话)

int i = 0 ,j = 0 ,k = 0;

while( 1 )
{
while( i < size.ws_col - 2 )//每一遍向右移动一个字符
{
while( j < i )//每一遍输出k个空格
{
printf(" ");
j++;
}
printf("R\r");

i++;

j = 0;
usleep(63240);//这是笑点
fflush(stdout);


}

while( i > 0 )
{
while( j < i )
{
printf(" ");
j++;
}
printf("R \r");

i--;

j = 0;
usleep(63240);
fflush(stdout);

}

i = 0;
continue;
}

printf("\n");

return 0 ;
}
Binary file added level1/p02_isPrime/isPrime
Binary file not shown.
36 changes: 36 additions & 0 deletions level1/p02_isPrime/isPrime.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <stdio.h>

int main()
{
int num;

scanf("%d" ,&num);

if (num < 2)
{
printf("N\n");
}
else if (num == 2)
{
printf("Y\n");
}

else
{
for(int i = 2; i < num; i++)
{
if (num % i == 0)
{
printf("N\n");
break;
}
else if (i == num)
{
printf("Y\n");
break;
}
}
}

return 0;
}
Binary file added level1/p03_Diophantus/Diophantus
Binary file not shown.
24 changes: 24 additions & 0 deletions level1/p03_Diophantus/Diophantus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>

float age_son ,age_count;

int main()
{
for( int age_DIO = 1.0; age_DIO < 200.0; ++age_DIO )
{
//printf("%d\n",(int)age_DIO);
age_count = age_DIO;
age_son = age_DIO / 2.0;
age_count = age_count - age_DIO / 6.0 ;
age_count = age_count - age_DIO / 12.0;
age_count = age_count - age_DIO / 7.0;
age_count = age_count - 5.0;
if ( age_count == age_son + 4.0 )
{
printf("%d\n" ,(int)age_DIO);
break;
}
}

return 0;
}
File renamed without changes.
27 changes: 27 additions & 0 deletions level1/p04_narcissus/narcissus.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>
#include <math.h>

double num_h ,num_d ,num_n;
int num;

int main()
{
for( num_h = 1.0; num_h < 10.0; ++num_h)
{
for( num_d = 0.0; num_d < 10.0; ++num_d)
{
for( num_n = 0.0; num_n < 10.0; ++num_n)
{
num = (int)pow(num_h , 3.0 ) + (int)pow(num_d , 3.0 ) + (int)pow(num_n , 3.0 );
if ( num == num_h*100 + num_d*10 + num_n )
{
printf("%d\n" ,num);
}

}

}

}
return 0 ;
}
Binary file added level1/p05_allPrimes/allPrimes
Binary file not shown.
56 changes: 56 additions & 0 deletions level1/p05_allPrimes/allPrimes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int tags[ 10000 ];
int num;

int main()
{
clock_t start, finish;
start = clock();
for(int i = 0; i < 10000; i++)
{
tags[ i ] = 1;//预设良民证
}

for(int num = 2; num <= 100; num++)//素因数检查仅到100即可
{
if (!tags[ num ])//检查良民证
{
++num;
}
else
{
for(int j = 2; j < 5000; j++) //拿走符合条件的num的倍数的良民证
{
if (num*j <= 10000)
{
tags[ num*j ] = 0;
}
else
{
break;
}

}

}


}
for(int l = 2; l < 10000; l++)//输出有良民证的数字
{
if (tags[ l ])
{
printf("%d\n" ,l);
}

}
finish = clock();
double total_time = (double) (finish - start) / CLOCKS_PER_SEC;
printf("%f seconds/n",total_time);

return 0;

}
Binary file added level1/p06_Goldbach/Goldbach
Binary file not shown.
40 changes: 40 additions & 0 deletions level1/p06_Goldbach/Goldbach.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <stdio.h>

int isPrime(int num)
{
if (num < 2)
{
return 0;
}
else if (num == 2)
{
return 1;
}
else
{
for(int i = 2; i < num; i++)
{
if (num % i == 0)
{
return 0;
}
}
}
return 1;
}

int main()
{
for(int l = 4; l < 102; l = l + 2)
{
for(int k = 1; k <= l/2; k++)
{
if ((isPrime( k ))&&(isPrime( l - k )))
{
printf("%d = %d + %d\n" ,l ,k ,l-k);
}
}
}

return 0;
}
Binary file added level1/p07_encrypt_decrypt/encrypt_decrypt
Binary file not shown.
Loading