Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute C Online

#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言語 ログの並び替え 文字列で検索

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.