#include <stdio.h> int main(void) { int a,b,c,d,e; int j = 0; int index = 0; //int array[10] = {1,3,5,7,8,9,2,4,6}; int array[10]; FILE *fp; fp = fopen("before_sort.txt","r"); if(fp == NULL){ printf( "ファイルオープンエラー\n"); return 0; } while((a = fscanf(fp,"%d",&b)) != EOF) { //printf("%d",b); array[index] = b; printf("%d",array[index]); index++; } //printf("\n"); for(c = 0;c < 9;c++){ printf("\n"); for(d = 0;d < 9;d++){ if(array[c] < array[d]){ e = array[c]; //printf("%d\n",e); array[c] = array[d]; //printf("%d\n",a[j]); array[d] = e; } printf("%d",array[index]); } } fclose(fp); return 0; } //C言語 ログの並び替え 文字列で検索
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more