1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
include <iostream>
#include <stdio.h>
using namespace std;
main ()
{
FILE* f;
f=fopen("numbers.txt", "r");
int n,m,x,v[20],i=1,u[20],j=1;
fscanf(f,"%d %d",&m,&n);
z=m;
while(z!=0)
{fscanf(f,"\n %d ",&x); /*this is what I don't understand, at school we were told that we must put "\n"
so that the compiler gets on the next line and also the space after "%d" because the numbers
in the file are parted by 1 space - and today I completely erased the separators (\n, space,
I even made m++ to see if the result is different) but the display result remained the same */
v[i]=x; i++; z--;
}
z=n;
while(z!=0)
{
fscanf(f,"\n \n %d ",&x); //these too (\n \n ' ')
u[j]=x; j++; z--;
}
|