Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.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 sortiraj(char *niza, int n) {
- int i, j;
- for(i = 0; i < n - 1; i++) {
- for(j = 0; j < n - 1 - i; j++) {
- if (niza[j] > niza[j+1]) {
- int temp = niza[j];
- niza[j] = niza[j+1];
- niza[j+1] = temp;
- }
- }
- }
- }
- int main() {
- wtf();
- // vashiot kod ovde
- FILE *f;
- if ( (f = fopen("datoteka.txt","r")) == NULL) {
- printf("Unable to open");
- return -1;
- }
- int cifri = 0, i;
- char niza[MAX], broevi[MAX];
- while((fgets(niza, MAX, f)) != NULL) {
- for(i=0; i<strlen(niza); i++) {
- if(isdigit(niza[i])) {
- cifri++;
- broevi[i] = niza[i];
- }
- }
- sortiraj(broevi, i);
- printf("%d:",cifri);
- for(int i = 0; i < cifri - 1; i++)
- printf("%d", broevi[i]);
- printf("\n");
- }
- fclose(f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement