forked from QSCTech/zju-icicles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
6,068 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include<stdio.h> | ||
int RemoveZeroElement(int * a,int n) | ||
{ | ||
int i,j; | ||
for(i=0;i<n;i++) | ||
{ | ||
if(a[i]==0){ | ||
for(j=i;j<n-1;j++) | ||
a[j]=a[j+1]; | ||
n--; | ||
i--; | ||
} | ||
} | ||
return n; | ||
} | ||
int main() | ||
{ | ||
int i,j; | ||
int a[10]={0,1,0,3,4,5,6,7,8,0}; | ||
i=RemoveZeroElement(a,10); | ||
for(j=0;j<i;j++) | ||
printf("%2d",a[j]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include<stdio.h> | ||
int RemoveDuplicates(int * array,int n) | ||
{ | ||
int i,j; | ||
int temp; | ||
for(i=0;i < n-1;i++) | ||
{ | ||
if(array[i] != -1) | ||
{ | ||
temp = array[i]; | ||
for(j=i+1;j < n;j++) | ||
{ | ||
if(array[j] == temp) | ||
array[j] = 0; | ||
} | ||
} | ||
} | ||
for(i=0;i<n;i++) | ||
{ | ||
if(array[i]==0){ | ||
for(j=i;j<n-1;j++) | ||
array[j]=array[j+1]; | ||
n--; | ||
i--; | ||
} | ||
} | ||
return n; | ||
} | ||
int main() | ||
{ | ||
int i; | ||
int a[13] = {65,72,75,79,82,82,84,84,84,86,90,94,95}; | ||
int nScores = 13; | ||
nScores = RemoveDuplicates(a,nScores); | ||
for(i=0;i<nScores;i++) | ||
printf("%3d",a[i]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include<stdio.h> | ||
#include<stdlib.h> | ||
#include<time.h> | ||
void RanArray(int * array) | ||
{ | ||
int temp = array[0]; | ||
int tempi; | ||
int tempj; | ||
int j = 0 ; | ||
int i; | ||
int count; | ||
for(i=0;i<52;i++) | ||
{ | ||
for(j=0;j<52;j++) | ||
{ | ||
if(array[j] <= temp) | ||
{ | ||
tempi = j; | ||
temp = array[j]; | ||
} | ||
} | ||
srand((unsigned int)time(NULL)+(unsigned int)(tempj*tempj+7*temp+5*temp)); | ||
for(count=0;count<10000000;count++); | ||
tempj = rand()%52; | ||
temp = array[tempi]; | ||
array[tempi] = array[tempj]; | ||
array[tempj] = temp; | ||
} | ||
} | ||
int main() | ||
{ | ||
int a[52]; | ||
int i; | ||
for(i=0;i<52;i++) | ||
a[i]=i+1; | ||
RanArray(a); | ||
for(i=0;i<52;i++) | ||
printf("%3d\n",a[i]); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include<stdio.h> | ||
void SortIntegerArray(int * a) | ||
{ | ||
int i = 0; | ||
int j = 0; | ||
int tmp = 0; | ||
for(i = 1;i<8;i++) | ||
{ | ||
tmp = a[i]; | ||
j = i-1; | ||
while(j>=0 && tmp<a[j]) | ||
{ | ||
a[j+1] = a[j]; | ||
j--; | ||
} | ||
a[j+1] = tmp; | ||
} | ||
} | ||
int main() | ||
{ | ||
int i; | ||
int a[8]={31,41,59,26,53,58,97,93}; | ||
SortIntegerArray(a); | ||
for(i=0;i<8;i++) | ||
printf("%3d\n", a[i]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Project: work4 | ||
# Makefile created by Dev-C++ 5.5.3 | ||
|
||
CPP = g++.exe | ||
CC = gcc.exe | ||
WINDRES = windres.exe | ||
OBJ = main.o libgraphics/exceptio.o libgraphics/genlib.o libgraphics/graphics.o libgraphics/random.o libgraphics/simpio.o libgraphics/strlib.o | ||
LINKOBJ = main.o libgraphics/exceptio.o libgraphics/genlib.o libgraphics/graphics.o libgraphics/random.o libgraphics/simpio.o libgraphics/strlib.o | ||
LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib" -L"C:/Program Files (x86)/Dev-Cpp/MinGW32/mingw32/lib" -static-libstdc++ -static-libgcc -mwindows -g3 | ||
INCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" | ||
CXXINCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW32/lib/gcc/mingw32/4.7.2/include/c++" | ||
BIN = work2.exe | ||
CXXFLAGS = $(CXXINCS) -g3 | ||
CFLAGS = $(INCS) -g3 | ||
RM = rm -f | ||
|
||
.PHONY: all all-before all-after clean clean-custom | ||
|
||
all: all-before $(BIN) all-after | ||
|
||
clean: clean-custom | ||
${RM} $(OBJ) $(BIN) | ||
|
||
$(BIN): $(OBJ) | ||
$(CC) $(LINKOBJ) -o $(BIN) $(LIBS) | ||
|
||
main.o: main.c | ||
$(CC) -c main.c -o main.o $(CFLAGS) | ||
|
||
libgraphics/exceptio.o: libgraphics/exceptio.c | ||
$(CC) -c libgraphics/exceptio.c -o libgraphics/exceptio.o $(CFLAGS) | ||
|
||
libgraphics/genlib.o: libgraphics/genlib.c | ||
$(CC) -c libgraphics/genlib.c -o libgraphics/genlib.o $(CFLAGS) | ||
|
||
libgraphics/graphics.o: libgraphics/graphics.c | ||
$(CC) -c libgraphics/graphics.c -o libgraphics/graphics.o $(CFLAGS) | ||
|
||
libgraphics/random.o: libgraphics/random.c | ||
$(CC) -c libgraphics/random.c -o libgraphics/random.o $(CFLAGS) | ||
|
||
libgraphics/simpio.o: libgraphics/simpio.c | ||
$(CC) -c libgraphics/simpio.c -o libgraphics/simpio.o $(CFLAGS) | ||
|
||
libgraphics/strlib.o: libgraphics/strlib.c | ||
$(CC) -c libgraphics/strlib.c -o libgraphics/strlib.o $(CFLAGS) |
Oops, something went wrong.