Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define N 200
- #define M 31
- int main()
- {
- FILE *f;
- int i, db;
- printf("\n2.feladat: \n");
- f=fopen("szotar.txt","r+");
- char szot[N][M];
- i=0;
- while(!feof(f))
- {
- fscanf(f,"%s",&szot[i]);
- i++;
- }
- db=i-1;
- ///////////////////////////////////
- // sorbarendezes: (buborekrendezes)
- int j,k;
- for (j=0; j<db-1; j++) {
- for (k=j+1; k<db; k++) {
- if (strcmp(szot[j], szot[k]) > 0) {
- char s[M];
- strcpy(s, szot[j]);
- strcpy(szot[j], szot[k]);
- strcpy(szot[k], s);
- }
- }
- }
- ///////////////////////////////////
- for(i=0;i<db;i++)
- printf("%s ",szot[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement