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

22920142203792 - 陈贤鹏 #102

Open
wants to merge 11 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
4 changes: 2 additions & 2 deletions assignments/shell/AddUsers/addUsers.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#
#!/bin/bash
#
# useradd
# chpasswd
# chown
# chmod
# edquota
#

#echo
9 changes: 9 additions & 0 deletions assignments/shell/AddUsers/addUsers.sh~
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
#
# useradd
# chpasswd
# chown
# chmod
# edquota
#

Binary file added experiments/gcc-1-hello-world/abc
Binary file not shown.
1 change: 1 addition & 0 deletions experiments/gcc-1-hello-world/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

int main(void) {
printf("Hello world!\n");
printf("another Hello world!\n");
return 0;
}
6 changes: 6 additions & 0 deletions experiments/gcc-1-hello-world/main.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int main(void) {
printf("Hello world!\n");
return 0;
}
7 changes: 6 additions & 1 deletion experiments/gcc-2-multi-source/calculator.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "include/calculator.h"

#include <stdio.h>
int sum(int x, int y) {
return x + y;
}
Expand All @@ -13,5 +13,10 @@ int multiply(int x, int y) {
}

int divide(int x, int divisor) {
if(divisor != 0)
return x / divisor;
else{
printf("error:divisor can not be 0\n");
return -1;
}
}
22 changes: 22 additions & 0 deletions experiments/gcc-2-multi-source/calculator.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "include/calculator.h"

int sum(int x, int y) {
return x + y;
}

int subtract(int x, int y) {
return x - y;
}

int multiply(int x, int y) {
return x * y;
}

int divide(int x, int divisor) {
if(divisor != 0)
return x / divisor;
else{
echo("error:divisor can not be 0\n");
return -1;
}
}
2 changes: 1 addition & 1 deletion experiments/gcc-2-multi-source/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <stdio.h>

#include "include/calculator.h"
int main(void) {
int x, y;

Expand Down
12 changes: 12 additions & 0 deletions experiments/gcc-2-multi-source/main.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdio.h>

int main(void) {
int x, y;

x = 2;
y = 3;

printf("%d + %d = %d\n", x, y, sum(2, 3));

return 0;
}
Empty file modified experiments/gcc-3-real-project/Makefile
100644 → 100755
Empty file.
6 changes: 6 additions & 0 deletions experiments/gcc-3-real-project/calculator.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "include/calculator.h"
#include <stdio.h>

int sum(int x, int y) {
return x + y;
Expand All @@ -13,5 +14,10 @@ int multiply(int x, int y) {
}

int divide(int x, int divisor) {
if(divisor != 0)
return x / divisor;
else{
printf("error:divisor can not be 0\n");
return -1;
}
}
22 changes: 22 additions & 0 deletions experiments/gcc-3-real-project/calculator.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "include/calculator.h"
#include"include.h"
int sum(int x, int y) {
return x + y;
}

int subtract(int x, int y) {
return x - y;
}

int multiply(int x, int y) {
return x * y;
}

int divide(int x, int divisor) {
if(divisor != 0)
return x / divisor;
else{
printf("error:divisor can not be 0\n");
return -1;
}
}
Binary file added experiments/gcc-3-real-project/main
Binary file not shown.
14 changes: 14 additions & 0 deletions experiments/gcc-3-real-project/main.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdio.h>

#include "include/calculator.h"

int main(void) {
int x, y;

x = 2;
y = 3;

printf("%d - %d = %d\n", x, y, subtract(2, 3));

return 0;
}
9 changes: 9 additions & 0 deletions experiments/真实的C项目/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
main:main.o calculator.o
gcc main.o calculator.o -o main
main.o:main.c
gcc -c main.c
calculator.o:calculator.c
gcc -c calculator.c

clean:
rm main *.o
9 changes: 9 additions & 0 deletions experiments/真实的C项目/calculator.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "include/calculator.h"


int compare(int a,int b){
if(a>b)
return 1;
else
return 0;
}
9 changes: 9 additions & 0 deletions experiments/真实的C项目/calculator.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "include/calculator.h"


bool compare(int a,int b){
if(a>b)
return true;
else
return false;
}
6 changes: 6 additions & 0 deletions experiments/真实的C项目/include/calculator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _CALC_H
#define _CALC_H

int compare(int a,int b);

#endif //_CALC_H
6 changes: 6 additions & 0 deletions experiments/真实的C项目/include/calculator.h~
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _CALC_H
#define _CALC_H

bool compare(int a,int b);

#endif //_CALC_H
Binary file added experiments/真实的C项目/main
Binary file not shown.
14 changes: 14 additions & 0 deletions experiments/真实的C项目/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <stdio.h>

#include "include/calculator.h"

int main(void) {
int x,y;
x=3,y=2;
printf("x>2:");
if(compare(x,y)>0)
printf("true\n");
else
printf("false\n");
return 0;
}
10 changes: 10 additions & 0 deletions experiments/真实的C项目/main.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <stdio.h>

#include "include/calculator.h"

int main(void) {
int x,y;
x=3,y=2;
printf("x>2:",compare(x,y)>0?printf("true\n"):printf("false\n"));
return 0;
}
Empty file.
36 changes: 36 additions & 0 deletions experiments/编译器优化作业/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
result:main array calculator
gcc main.o array.o calculator.o -o result

main: main_clean main.c
gcc -c -O0 main.c
main_optimize: main_clean main.c
gcc -c -O2 main.c
main_clean:
if [ -e main.o ] ; then rm main.o ; fi


calculator:calculator.c
gcc -c calculator.c

array: array_clean array.c
gcc -c -O0 array.c
array_optimize: array_clean array.c
gcc -c -O2 array.c
array_clean:
if [ -e array.o ] ; then rm array.o ; fi


release: main_optimize array_optimize calculator
gcc main.o array.o -o release

diff: result release
./result
./release

clean:
if [ -e result ] ; then rm result ; fi

if [ -e release ] ; then rm release ; fi

rm *.o

35 changes: 35 additions & 0 deletions experiments/编译器优化作业/array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>

#include "include/array.h"

#define VECTOR_LENGTH 2048

void array_get(int arrayX[VECTOR_LENGTH][VECTOR_LENGTH],int arrayY[VECTOR_LENGTH][VECTOR_LENGTH],int n1,int m1,int n2,int m2){
int i,j;
for(i = 0 ; i < n1 ; i ++ )
for(j = 0 ; j < m1; j++ )
scanf("%d",&arrayX[i][j]);
for(i = 0 ; i < n2 ; i ++ )
for(j = 0 ; j < m2; j++ )
scanf("%d",&arrayY[i][j]);
}

void array_multiply(int vector_a[VECTOR_LENGTH][VECTOR_LENGTH], int vector_b[VECTOR_LENGTH][VECTOR_LENGTH], int vector_c[VECTOR_LENGTH][VECTOR_LENGTH],int n1,int m1,int n2,int m2){
if(m1!=n2){
printf("Error!\n");
return ;
}
int i,j,k;
for(i = 0 ;i < n1; i ++)
for(k = 0 ;k < m2 ; k++)
vector_c[i][k] = 0;
for(i = 0 ; i < n1; i++)
for(j = 0 ; j < m1 ;j++)
for(k = 0;k < m2 ; k++)
vector_c[i][k] += vector_a[i][j]*vector_b[j][k];
}





35 changes: 35 additions & 0 deletions experiments/编译器优化作业/array.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <stdio.h>

#include "include/array.h"

#define VECTOR_LENGTH 2048

void array_get(int arrayX[VECTOR_LENGTH][VECTOR_LENGTH],int arrayY[VECTOR_LENGTH][VECTOR_LENGTH],int n1,int m1,int n2,int m2){
int i,j;
for(i = 0 ; i < n1 ; i ++ )
for(j = 0 ; j < m1; j++ )
scanf("%d",&arrayX[i][j]);
for(i = 0 ; i < n2 ; i ++ )
for(j = 0 ; j < m2; j++ )
scanf("%d",&arrayY[i][j]);
}

void array_multiply(int vector_a[VECTOR_LENGTH][VECTOR_LENGTH], int vector_b[VECTOR_LENGTH][VECTOR_LENGTH], int vector_c[VECTOR_LENGTH][VECTOR_LENGTH],int n1,int m1,int n2,int m2){
if(m1!=n2){
printf("Error!\n");
return ;
}
int i,j,k;
for(i = 0 ;i < n1; i ++)
for(k = 0 ;k < m2 ; k++)
vector_c[[i][k] = 0;
for(i = 0 ; i < n1; i++)
for(j = 0 ; j < m1 ;j++)
for(k = 0;k < m2 ; k++)
vector_c[i][k] += vector_a[i][j]*vector_b[j][k];
}





17 changes: 17 additions & 0 deletions experiments/编译器优化作业/calculator.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "include/calculator.h"

int sum(int x, int y) {
return x + y;
}

int subtract(int x, int y) {
return x - y;
}

int multiply(int x, int y) {
return x * y;
}

int divide(int x, int divisor) {
return x / divisor;
}
8 changes: 8 additions & 0 deletions experiments/编译器优化作业/include/array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _ARRAY_H
#define _ARRAY_H
#define VECTOR_LENGTH 2048
void array_get(int arrayX[VECTOR_LENGTH][VECTOR_LENGTH],int arrayY[VECTOR_LENGTH][VECTOR_LENGTH],int n1,int m1,int n2,int m2);

void array_multiply(int vector_a[VECTOR_LENGTH][VECTOR_LENGTH], int vector_b[VECTOR_LENGTH][VECTOR_LENGTH], int vector_c[VECTOR_LENGTH][VECTOR_LENGTH],int n1,int m1,int n2,int m2);

#endif
8 changes: 8 additions & 0 deletions experiments/编译器优化作业/include/array.h~
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _ARRAY_H
#define _ARRAY_H
#define VECTOR_LENGTH 2048
void array_get(int arrayX[VECTOR_LENGTH][VECTOR_LENGTH],int arrayY[VECTOR_LENGTH][VECTOR_LENGTH]);

void array_multiply(int vector_a[VECTOR_LENGTH][VECTOR_LENGTH], int vector_b[VECTOR_LENGTH][VECTOR_LENGTH], int vector_c[VECTOR_LENGTH][VECTOR_LENGTH]);

#endif
9 changes: 9 additions & 0 deletions experiments/编译器优化作业/include/calculator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef _CALC_H
#define _CALC_H

int sum(int x, int y);
int subtract(int x, int y);
int multiply(int x, int y);
int divide(int x, int divisor);

#endif //_CALC_H
Loading