Jan 13, 2012 at 8:34am UTC
template<class T>
void matrix_gen(T **t, int n, int m, int x, int y) {
for (int i=0;i<n;i++)
for (int j=0;j<m;j++)
t[i][j] = pick(x, y);
}
template<class T>
void matrix_add(T **tab1, T **tab2, T **tab3, int n, int m) {
for(int i=0;i<n;i++)
for(int j=0;j<m;j++) {
tab3[i][j] = tab2[i][j] + tab1[i][j];
}
}
template<class T> void add_to_list(T x, struct lsz <T> *h) {
struct lsz <T> *nowy;
while(h->next!=NULL)
h = h->next;
nowy = new struct lsz <T>;
nowy->x = x;
nowy->next = NULL;
h->next = nowy;
}
template<class T> int delete_from_list(struct lsz <T> *h, struct lsz <T> *x) {
struct lsz <T> *tmp;
while(h->next != x) {
if(h->next==NULL)
return -1;
h = h->next;
}
tmp = h->next->next;
delete h->next;
h->next = tmp;
}
template<class T> void print_list(struct lsz <float> *h) {
if(h != NULL)
while(h != NULL) {
cout << h->x << endl;
h = h->next;
}
}
template<class T> void print_list(struct lsz <Osoba> *h) {
int i = 1;
while(h != NULL) {
cout << i << ": Imie: "<< h->x.imie << " Nazwisko: " << h->x.nazwisko << " Plec: " << h->x.plec << " Wiek: " << h->x.wiek << endl;
h = h->next;
i++;
}
}
template<class T> void print_list(struct lsz <Student> *h) {
int i = 1;
while(h != NULL) {
cout << i << ": Imie: "<< h->x.imie << " Nazwisko: " << h->x.nazwisko << " Data ur: " << h->x.data_ur << " Nr indeksu: " << h->x.nr_indeksu << endl;
h = h->next;
i++;
}
}
Feb 6, 2012 at 1:31pm UTC
FILE* pl1;
pl1=fopen("naz.txt","rb");
for(int i=0;i<1;i++){
fread(nowe[i].imie,1,sizeof(nowe[i].imie),pl1);
fread(&nowe[i].wiek,1,sizeof(nowe[i].wiek),pl1);
cout<<nowe[i].imie<<endl;}
fclose(pl);
fclose(pl1);
for(int i=0;i<n;i++){
nowe[i].imie=(char*)malloc(sizeof(char));
cin>>nowe[i].imie;
cin>>nowe[i].wiek;
fwrite(nowe[i].imie,1,sizeof(nowe[i].imie),pl);
fstream pl;
pl.open("tab.txt",ios::out);
int n,m;
cin>>n>>m;
int **tab;
tab=new int*[n];
for(int i=0;i<n;i++)
tab[i]=new int[m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
tab[i][j]=(i+1)*(j+1);
pl<<tab[i][j]<<"\t";
}pl<<endl;}
pl.close();
delete tab;
plik.write((char*)nowe[i].imie,sizeof(nowe[i].imie));
plik.write((char*)&nowe[i].wiek,sizeof(nowe[i].wiek));