Jump to content

Program v C pomoc


Skermaster

Recommended Posts

Prosím pomohol by niekto s programom?

program mám napísať v programe DevC++

Zadanie:

Napíšte program, ktorý do súboru vstup.txt zapíše čísla od 1 do 100 tak, aby v každom riadku bolo 10 čísel a 10 stĺpcov. Do súboru vystup.txt vypíšte len čísla, ktoré sú deliteľné číslom 3 alebo 4. 

 

Link to comment
Share on other sites

Neviem ci v tom druhom subor chces cisla do 100, alebo ci ich chces znovu nejako usporiadat, toto ich vypise 1 do riadka do 100, upravit to verim zvladnes. Pouzit mozes aky program chces je to ciste C, zbehne ti to aj v roku 1989 :)
Nech sa paci

#include <stdio.h>
#include <stdlib.h>

int main(){
        int i;
        FILE *f;

        f = fopen("vstup.txt","w");
        for(i=1;i<=100;i++){
                fprintf(f,"%i",i);
                if(i%10==0)
                        fprintf(f,"\n");
                else
                        fprintf(f," ");
        }
        fclose(f);
        f = fopen("vystup.txt","w");
        for(i=1;i<=100;i++)
                if(i%3==0||i%4==0)
                        fprintf(f,"%i\n",i);
        fclose(f);
        return 0;
}
  • Upvote 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Additional information you can see at Privacy Policy