Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #define MAX 100
- //ne menuvaj!
- void wtf() {
- FILE *f = fopen("input.txt", "w");
- char c;
- while((c = getchar()) != EOF) {
- fputc(c, f);
- }
- fclose(f);
- }
- void sort(int *a,int *b)
- {
- int pom;
- pom=*a;
- *a=*b;
- *b=pom;
- }
- void sortniza(int b[],int n)
- {
- int i=0,j;
- for(i=0;i<n;i++)
- {
- for(j=0;j<n;j++)
- {
- if(b[i]<b[j])
- sort(&b[i],&b[j]);
- }
- }
- }
- int main() {
- wtf();
- char a[MAX],g;
- FILE *dato;
- int br=0,brojac,i;
- dato=fopen("input.txt","r");
- if(dato==NULL)
- {
- printf("Error");
- return -1;
- }
- while(fgets(a,MAX,dato))
- {
- g=0;
- br=0;
- int b[MAX];
- for(i=0;i<strlen(a);i++)
- {
- if(isdigit(a[i]))
- {br++;b[g]=a[i]-'0';g++;}
- }
- printf("%d:",br);
- sortniza(b,g);
- for(brojac=0;brojac<g;brojac++)
- {
- printf("%d",b[brojac]);
- }
- printf("\n");
- }
- fclose(dato);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement