Notes
Notes - notes.io |
#include <stdlib.h>
#include <process.h>
#include <string.h>
#define MAX_ROW 10
typedef struct Liste{
int per_no,index;
char isim[20],soyisim[20];
struct Liste *onceki,*sonraki;
}Listeler;
typedef struct Tablo{
Listeler list[MAX_ROW];
}Table;
Table table;
void initialize(){ // ilk bos degerlerin atanmasi
int i;
for(i=0; i<MAX_ROW ;i++){
table.list[i].per_no=-1;
table.list[i].index=-1;
table.list[i].isim[0]=' ';
table.list[i].soyisim[0]=' ';
table.list[i].onceki=NULL;
table.list[i].sonraki=NULL;
}
}
int Hash(int no){
int hash_index;
hash_index=no % MAX_ROW;
return hash_index;
}
void Hash_Ekleme(){
int no;
char ad[20],soyad[20];
Listeler *liste,*temp,*count;
FILE *dosya=fopen("Personeller.txt","r");
if(dosya==NULL){
printf("nDosya bulunamadi..");
exit(0);
}
else{
while(!feof(dosya)){
fscanf(dosya,"%d %s %s",&no,ad,soyad);
if(table.list[Hash(no)].index==-1){
table.list[Hash(no)].per_no=no;
strcpy(table.list[Hash(no)].isim,ad);
strcpy(table.list[Hash(no)].soyisim,soyad);
}
else{
liste=(Listeler *)malloc(sizeof(Listeler));
if(liste==NULL){
printf("nBellekte yeterli alan yok..");
exit(0);
}
else{
liste->index=Hash(no);
liste->per_no=no;
strcpy(liste->isim,ad);
printf("%sn",liste->isim);
strcpy(liste->soyisim,soyad);
printf("%sn",liste->soyisim);
liste->sonraki=NULL;
liste->onceki=NULL;
temp=&table.list[Hash(no)];
count=temp;
while(count->sonraki!=NULL){
if(count->sonraki==NULL){
while(count->sonraki!=NULL){
count=count->sonraki;
}
count->sonraki=temp;
}
while(temp->per_no<count->per_no){
count=count->sonraki;
}
count->sonraki=temp;
temp->onceki=count;
count->sonraki->onceki=temp;
}
}
}
}
}
}
void Hash_Listele(Table table){
int i;
Listeler *liste;
for(i=0;i<MAX_ROW;i++){
if(table.list[i].index!=-1){ //kayit varsa
printf("n%d, %s, %s",table.list[i].per_no,table.list[i].isim,table.list[i].soyisim);
// printf("n%d = %d % %d",table.list[i].index,table.list[i].per_no,MAX_ROW);
liste=table.list[i].sonraki;
while(liste!=NULL){
printf("n%d, %s, %s",table.list[i].per_no,table.list[i].isim,table.list[i].soyisim);
// printf("n%d = %d % %d",table.list[i].index,table.list[i].per_no,MAX_ROW);
liste=liste->sonraki;
}
}
else{ //kayit yoksa
printf("nBulunamadi!");
}
}
}
int main() {
initialize();
Hash_Ekleme();
Hash_Listele(table);
/* Listeler liste;
FILE *dosya;
dosya=fopen("Personeller.txt","r");
if(dosya==NULL){
printf("nDosya bulunamadi..n");
exit(0);
}
else{
while(!feof(dosya)){
fscanf(dosya,"%d %s %s",&liste.per_no,liste.isim,liste.soyisim);
Hash_Ekleme(Hash(liste.per_no),liste.isim,liste.soyisim);
printf("%d %s %sn",liste.per_no,liste.isim,liste.soyisim);
}
}
fclose(dosya);
*/ return 0;
}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team