Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main(void)
- {
- int i,j,n,a,str[500];
- FILE *fin, *fout;
- if ((fin = fopen("data1", "r")) == NULL)
- {
- printf("入力ファイルなし\n");
- exit(1);
- }
- if ((fout = fopen("data2", "w")) == NULL)
- {
- printf("出力ファイルなし\n");
- exit(1);
- }
- n = 0;
- while (( str[n] = fgetc(fin)) != EOF){
- n++;
- }
- for (i=0;i<n;i++)
- {
- for (j=i+1;j<n;j++)
- {
- if(str[i]>str[j])
- {
- a=str[i];
- str[i]=str[j];
- str[j]=a;
- }
- }
- fputc(str[i],fout);
- }
- fclose(fin);
- fclose(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement