Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main () {
- int mennyi;
- int i;
- char space = ' ';
- FILE * fp;
- fp = fopen ("szamok.txt","w");
- printf("Adja meg hany szamot szeretne bevinni!\n");
- scanf("%d",&mennyi);
- int tomb[mennyi];
- for(i=1; i<=mennyi; i++) {
- printf("Adja meg a %d . szamot!",i); scanf("%d",&tomb[i-1]);
- printf("\n");
- }
- printf("\nA bevitt tomb: \n");
- for (i=0; i<mennyi; i++)
- printf("%d ",tomb[i]);
- for(i=0; i<mennyi; i++) {
- if(tomb[i] % 2 == 0) {
- fprintf(fp,"%d",tomb[i]);
- fprintf(fp,"%c",space);
- }
- }
- printf("\n\nA paros szamok at lettek teve a szamok.txt-be...\n");
- fclose(fp);
- return 0;
- }
Add Comment
Please, Sign In to add comment