From 511de8b71f089f0fffa07ed7b153579878752cfc Mon Sep 17 00:00:00 2001 From: kemasama Date: Tue, 26 Apr 2022 19:03:03 +0900 Subject: [PATCH] code: code clean --- quick_sort/quick_sort | Bin 33943 -> 33943 bytes quick_sort/quick_sort.c | 37 +++++++++++-------------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/quick_sort/quick_sort b/quick_sort/quick_sort index fee08c746017d1c7ec1d0e308e7a2d6f6c82c412..d2033040789486d7563d8301d82d580efd1832a4 100755 GIT binary patch delta 703 zcmYjPOK1~O6umPq4NW(uAE|9KNs18?TG3Dt?I(@IMXZZL%_7=F1BHSF)CdK$YT8+t zE^ISQBn^HVi^?PjB0+e#Fv?JCurtbixbEHdC$hhX`;2B1=p?eB?J<@HwYlK9L z;n|p<48Pp%X)_Xm=1Eu{@N`U%=mtTp>H|q3Vahi^4BtA| zQLSc5#9A{V7g)XCM4{e<9!Bm_Q~VO$BBlcB*Yr6)_DF2-P7Zea(3|<{JoQLN5bN_n zKfN(x73em0R@yW0T0uy&aUjWCo=q-Ud^a38X--Z7fmL?=yw27^cF)+lBZIXiu^_V# zm8AQ%*EbKzr|kFKS>t5FcE(7N^1f3jrvcmMzZ delta 702 zcmbQ<$uzx_X~G4;8CDDoj0_A69V|cs2xe@2IG;%%vZp)Iy~!$Oiid|mt-)K9$rG3@ z7z;L^WZrK!Ieppbl9}-0Zv-KS3vcB`u|@*d<9T&MYH&im&^k`q?|6*93h6avF4Nc#W(>HD3b z4s`}P6etIB=qji~!47hsHM!eP*1`~I21q~H>>YL!b%A_vI0E%S!cA(&OQ0k71LI>w zbIcEUMuv$X`N=Qro-oeXeAYh1QD8b`lo}=*Hp(j&*g(>V3{Zq0sN)7S z&1gXRGd34CvN0)yns;|MlzlN-C49Kpm94Z_K<$AEBXfwcTd>v9C7&CMCQom6P*9Nk zbceU$XUjvkYey&K7m6G((wu63d9lQWubcm*oDbSN`FnGNLaJEZ<(N8O)i@KroRa$| Wd$t?K_P%Av%j`JLt+CJYTo?dK`1%0= diff --git a/quick_sort/quick_sort.c b/quick_sort/quick_sort.c index a82203e..64f20e4 100644 --- a/quick_sort/quick_sort.c +++ b/quick_sort/quick_sort.c @@ -70,21 +70,16 @@ int right // 右端(※配列の要素数ではない) int main() { - /* - int array[] = { - 10, 20, 30, 50, - 50, 10, 45, 65, - 76, 54, 56, 15, - 34, 31, 14, 17, - 14, 15, 11, 16, - 90, 19, 98, 76, - 75, 15, 161, 165, - 166, 167, 87, 86 - }; - */ + int i; + int j; + int c; + int length = 0; + int read_line_size = 512; + char read_line[read_line_size]; + FILE *fp; char dataFile[] = "data.txt"; - FILE *fp = fopen(dataFile, "r"); + fp = fopen(dataFile, "r"); if ( fp == NULL ) { printf("file can not open.\n"); @@ -92,25 +87,19 @@ main() } fseek(fp, 0, SEEK_SET); - int line_count = 0; - int c; while ( (c = fgetc(fp)) != EOF ) { if ( c == '\n') { - line_count++; + length++; } } - int array[line_count]; + int array[length]; fseek(fp, 0, SEEK_SET); - int read_line_size = 512; - char read_line[read_line_size]; - int j; - - for ( j = 0 ; j < line_count ; j++ ) + for ( j = 0 ; j < length ; j++ ) { fgets(read_line, read_line_size, fp); array[j] = atoi(read_line); @@ -118,12 +107,8 @@ main() fclose(fp); - int length = sizeof(array) / sizeof(int); - printf("Length: %d\n", length); quick_sort(array, 0, length - 1); - - int i ; for ( i = 0 ; i < length ; i++ ) {