• Downloads
  • ! Read Me !
  • Μαθήματα
  • Φοιτητικά
  • Τεχνικά Θέματα
  • Συζητήσεις
  • Happy Hour!
  • About THMMY.gr
 V  < 
Search:  
Welcome, Guest. Please login or register.
June 18, 2025, 11:24:18 am

Login with username, password and session length
Links
  Thmmy.gr portal
   Forum
   Downloads
   Ενεργ. Λογαριασμού
   Επικοινωνία
  
  Χρήσιμα links
   Σελίδα τμήματος
   Βιβλιοθήκη Τμήματος
   Elearning
   Φοιτητικά fora
   Πρόγραμμα Λέσχης
   Πρακτική Άσκηση
   Ηλεκτρονική Εξυπηρέτηση Φοιτητών
   Διανομή Συγγραμμάτων
   Ψηφιακό Καταθετήριο Διπλωματικών
   Πληροφορίες Καθηγητών
   Instagram @thmmy.gr
   mTHMMY
  
  Φοιτητικές Ομάδες
   ACM
   Aristurtle
   ART
   ASAT
   BEAM
   BEST Thessaloniki
   EESTEC LC Thessaloniki
   EΜΒ Auth
   IAESTE Thessaloniki
   IEEE φοιτητικό παράρτημα ΑΠΘ
   SpaceDot
   VROOM
   Panther
  
Πίνακας Ελέγχου
Welcome, Guest. Please login or register.
June 18, 2025, 11:24:18 am

Login with username, password and session length

Αναζήτηση

Google

THMMY.gr Web
Πρόσφατα
H Στοά των Off Topic
by Nikos_313
[Today at 08:53:31]

[Μεταφορά και Διανομή ΗΕ]...
by tzortzis
[Today at 07:55:05]

Πρακτική Άσκηση ΤΗΜΜΥ 201...
by chris_p30
[Today at 00:45:33]

Ισραήλ - Ιράν: Πόλεμος στ...
by Katarameno
[June 17, 2025, 21:32:50 pm]

[Ψηφιακά Ολοκληρωμένα Κυκ...
by tzortzis
[June 17, 2025, 21:25:42 pm]

[Εφ.Θερμοδυναμική] Γενικέ...
by PAPARI69
[June 17, 2025, 20:59:13 pm]

[Γραφική] Λυμένα θέματα
by okanpala
[June 17, 2025, 18:56:22 pm]

Τι ακούτε αυτήν τη στιγμή...
by Katarameno
[June 17, 2025, 14:25:00 pm]

Αντικατάστασης πυκνωτή σε...
by george14
[June 17, 2025, 13:58:20 pm]

Πότε θα βγει το μάθημα; -...
by tzortzis
[June 17, 2025, 13:19:53 pm]

Αποτελέσματα Εξεταστικής ...
by george14
[June 17, 2025, 12:08:25 pm]

[ΨEE] Γενικές απορίες και...
by Juror8
[June 17, 2025, 12:06:57 pm]

[Οργάνωση Υπολογιστών] Γε...
by RAFI
[June 16, 2025, 22:46:54 pm]

[Σ.Π.Η.Ε.] Γενικές απορίε...
by Nikos_313
[June 16, 2025, 19:49:00 pm]

[ΘΤΠΑ] Γενικές απορίες κα...
by Nikos_313
[June 16, 2025, 16:56:56 pm]

[Αρχές Οικονομίας] Να επι...
by _Trob
[June 16, 2025, 13:28:21 pm]

[Σ.Α.Π.Γ.] Εργασία 2025
by Nikos_313
[June 16, 2025, 12:13:45 pm]

[Διανεμημένη Παραγωγή] Γε...
by Διάλεξις
[June 16, 2025, 01:56:37 am]

[Σ.Π.Η.Ε.] Παλιά θέματα -...
by nmpampal
[June 15, 2025, 06:43:15 am]

Το thmmy.gr στο instagram...
by Mr Watson
[June 15, 2025, 00:50:23 am]
Στατιστικά
Members
Total Members: 9961
Latest: Poli
Stats
Total Posts: 1426709
Total Topics: 31711
Online Today: 215
Online Ever: 2093
(April 17, 2025, 08:47:49 am)
Users Online
Users: 61
Guests: 91
Total: 152
sylaiangel
Billyskotsikas
dionmant
bit11
salonikios
Τζιτζίς
sofipout
alexter
chris_p30
karthos
jimalexoud
idtr10
Andreas04
ThanosTheTT
glavdakis
Νικηφόρος Πατσιούρας
sofaki
tzortzis
eseleng
Chr1sgr
aimgk
geojohn
aris123321
aachmet
grepanis
spoun
mikebel
babistso
Pastellaki
elena_k
narcos
kkotsopo
Annapar
dkoukn
mgrivab
George15
kakousios
Nikoletta
Fenia04
mavropan
nikpapoutsi
KG03
Captain
Zoe06
DarkMagiK06
angiek
Carot1456
george14
okatapo
papatmaria
vagelismo
papajohnn06
noimaginationforthis
gntitsios
Tsn
vajim
Εμφάνιση

Νέα για πρωτοετείς
Είσαι πρωτοετής;... Καλώς ήρθες! Μπορείς να βρεις πληροφορίες εδώ. Βοήθεια για τους καινούργιους μέσω χάρτη.
Κατεβάστε εδώ το Android Application για εύκολη πρόσβαση στο forum.
Ανεβάζετε τα θέματα των εξετάσεων στον τομέα Downloads με προσοχή στα ονόματα των αρχείων!

Νέα!
  Όταν ανεβάζουμε φωτογραφίες στις Ανακοινώσεις και Έκτακτα νέα, βάζουμε τη μεγαλύτερη πλευρά 400 (width=400 ή height=400 ). π.χ. [img height=400 (κλείνει η αγκύλη) 
THMMY.gr > Forum > Μαθήματα Βασικού Κύκλου > 1ο Εξάμηνο > Δομημένος Προγραμματισμός (Moderators: Tasos Bot, tzortzis, Nekt) > Εργασία E 2007
0 Members and 1 Guest are viewing this topic.
Pages: 1 ... 5 6 [7] Go Down Print
Author Topic: Εργασία E 2007  (Read 12309 times)
^^DaRk_HunTeR
Μόνιμος κάτοικος ΤΗΜΜΥ.gr
******
Gender: Male
Posts: 2149


0001 0010 0100 0010


View Profile
5η Εργασία-συζήτηση
« Reply #90 on: July 04, 2007, 02:02:37 am »

Quote from: A.B.US.E on June 29, 2007, 17:04:52 pm
Code:
/* This code Provided to you by A.B.US.E. (a.k.a. Addicted to Binary USage Entertainment)
 *
 * It's been an hour of stupidity and laming around until we got this piece of garbage
 * work. We, of course, obfuscated the code just to make sure you guys really try to
 * write that thing down.
 *
 * For those who believe that this program is a useless piece of junk that all it does
 * is irritating you... You're absolutely right...
 *
 * Kisses fly to all those who try hard to learn something out of these junks...
 * Flames fly to all those who enforce people to work on such useless programs...
 * Think differently...
 *
 * We will release the original code once your deadline is over... :-)
 * Until then enjoy the summer :-)
 */

/* $ABUSE.Code: test.c,v 1.0 2007/06/28 7:17:31 ABUSE Exp $ */

#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>

#define le float
#define lg int
#define lq void
#define lf for
#define ls if
#define lv break
#define lw main
#define lo fprintf
#define ln stderr
#define lr scanf
#define lp malloc
#define lm sizeof
#define lt memset

le* *ld;lg*lh;lg lc;lq lu(lq){lg la,lb,li,lk;le lj;lf(la=0;la<lc;la++
){ls(la+1==lc)lv;lf(lb=0;lb<lh[la];lb++){lj=ld[la][lb];lf(li=la+1;li<
lc;li++){lf(lk=0;lk<lh[li];lk++){ls(lj==ld[li][lk])ld[li][lk]=0;}}}}}
lg lw(lq){le lj, *lx;lg la,lb,ll;lo(ln,"\x54\x79\x70\x65\x20\x74\x68"
"\x65\x20\x6e\x75\x6d\x62\x65\x72\x20\x6f\x66\x20\x53\x74\x61\x74\x69"
"\x6f\x6e\x73\x20\x3a\x20");lr("\x25\x69",&lc);lh=(lg* )lp(lc*lm(lg));
lt(lh,0,lm(lg) *lc);ld=(le* * )lp(lc*lm(le* ));lt(ld,0,lc*lm(le* ));
lf(la=0;la<lc;la++){lo(ln,"\x54\x79\x70\x65\x20\x74\x68\x65\x20\x6e"
"\x75\x6d\x62\x65\x72\x20\x6f\x66\x20\x66\x72\x65\x71\x75\x65\x6e\x63"
"\x69\x65\x73\x20\x66\x6f\x72\x20\x73\x74\x61\x74\x69\x6f\x6e\x20\x25"
"\x64\x20\x3a\x20",la);lr("\x25\x69",&lb);lh[la]=lb;ld[la]=(le* )lp(
lb*lm(le));lf(ll=0;ll<lb;ll++){lo(ln,"\x54\x79\x70\x65\x20\x74\x68"
"\x65\x20\x66\x72\x65\x71\x75\x65\x6e\x63\x79\x20\x25\x64\x20\x66\x6f"
"\x72\x20\x73\x74\x61\x74\x69\x6f\x6e\x20\x25\x64\x20\x3a\x20",ll,la);
lr("\x25\x66",&lj);ld[la][ll]=lj;}}lu();lf(la=0;la<lc;la++){lf(lb=0;
lb<lh[la];lb++){ls(ld[la][lb])lo(ln,"\x53\x74\x61\x74\x69\x6f\x6e\x20"
"\x25\x64\x20\x63\x61\x6e\x20\x67\x65\x74\x20\x66\x72\x65\x71\x75\x65"
"\x6e\x63\x79\x20\x25\x66\x20\x28\x25\x64\x29\n",la,ld[la][lb],lb);}}
}

Quote of the month :
Quote from: Bo@rD-RiDeR on June 27, 2007, 16:11:51 pm
έστω i η σειρά και j η στήλη

Τότε 

scanf(" % f ", & p [ i ] [j ] );
ή
scanf(" % f ", ( p [ i]  + j ) );
ή
scanf(" % f ", ( * ( p + i ) + j ) );

'ολα το ίδιο είναι,διαλέγεις κ παίρνεις! Tongue

Best regards...

Addicted to Binary USage Entertainment...
"Sniffing your bits since 1952..."
the time has come Tongue let us see.................enlighten us
Logged

Without order nothing can exist without chaos nothing can evolve

Timeo hominem unius libri
The minstrel
A.B.US.E
Αρχάριος/Αρχάρια

Gender: Male
Posts: 3



View Profile WWW
5η Εργασία-συζήτηση
« Reply #91 on: July 04, 2007, 14:59:41 pm »

Quote
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness. ... hat whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, having its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness.
The Decleration of Independence - July 4th, 1776

We decided to post two codes one that uses realloc() and one that doesn't Smiley

The obfuscated source code came from the one which doesn't use realloc().

Both programs work Smiley

Some Remarks :
What one should do here is to create a pointer that each of its members will hold memories to other pointers. Memory is allocated linearly (using malloc()) and thus the pointers can be used as arrays. Note that after each allocation we call memset() to initialize to 0 unless we immediately initialize our data by other means.
Using stderr instead of stdout allows for unbuffered output (thus we use fprintf() instead of printf()). That's an explanation cause some people got really perplexed with this.. Tongue

Have fun and ask any questions here Smiley

Without realloc() :
Code:
/* This code Provided to you by A.B.US.E. (a.k.a. Addicted to Binary USage Entertainment)
 *
 * It's been an hour of stupidity and laming around until we got this piece of garbage
 * work. We, of course, obfuscated the code just to make sure you guys really try to
 * write that thing down.
 *
 * For those who believe that this program is a useless piece of junk that all it does
 * is irritating you... You're absolutely right...
 *
 * Kisses fly to all those who try hard to learn something out of these junks...
 * Flames fly to all those who enforce people to work on such useless programs...
 * Think differently...
 *
 * We will release the original code once your deadline is over... :-)
 * Until then enjoy the summer :-)
 */

/* $ABUSE.Code: t.c,v 1.0 2007/06/28 19:17:31 ABUSE Exp $ */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

float **stations_freqs;
int *n_freqs;
int station_num;

/* Check all frequencies as follows :
 * Take current station and zero out all matching frequencies to the
 * above stations. Frequencies that are zero should not be checked.
 */
void check (void)
{
int i, c, s, x;
float freq;

for (i = 0; i < station_num; i++)
{
if (i + 1 == station_num)
break;

for (c = 0; c < n_freqs[i]; c++)
{
freq = stations_freqs[i][c];

/* Speed Hack */
if (!freq)
continue;

for (s = i+1; s < station_num; s++)
{
for (x = 0; x < n_freqs[s]; x++)
{
if (freq == stations_freqs[s][x])
stations_freqs[s][x] = 0;
}
}
}
}
}

int main (void)
{
float freq, *pos;
int i, c, p;

/* Read the number of Stations */
fprintf(stderr, "Type the number of Stations : ");
scanf("%i", &station_num);

n_freqs = (int *)malloc(station_num * sizeof(int));
memset(n_freqs, 0, sizeof(int) * station_num);

stations_freqs = (float **)malloc(station_num * sizeof(float *));
memset(stations_freqs, 0, station_num * sizeof(float *));

/* Now for each station read the number of freqs
* then read each freq.
*/

for (i = 0; i < station_num; i++)
{
fprintf(stderr, "Type the number of frequencies for station %d : ", i);
scanf("%i", &c);
n_freqs[i] = c;

/* Allocate enough space for them */
stations_freqs[i] = (float *)malloc(c*sizeof(float));

/* Read them and place them */
for (p = 0; p < c; p++)
{
fprintf(stderr, "Type the frequency %d for station %d : ", p, i);
scanf("%f", &freq);
stations_freqs[i][p] = freq;
}
}

check();

for (i = 0; i < station_num; i++)
{
for (c = 0; c < n_freqs[i]; c++)
{
if (stations_freqs[i][c])
fprintf(stderr, "Station %d can get frequency %f (%d)\n", i, stations_freqs[i][c], c);
}
}

return 0;
}

With realloc() :
Code:
/* This code Provided to you by A.B.US.E. (a.k.a. Addicted to Binary USage Entertainment)
 *
 * It's been an hour of stupidity and laming around until we got this piece of garbage
 * work. We, of course, obfuscated the code just to make sure you guys really try to
 * write that thing down.
 *
 * For those who believe that this program is a useless piece of junk that all it does
 * is irritating you... You're absolutely right...
 *
 * Kisses fly to all those who try hard to learn something out of these junks...
 * Flames fly to all those who enforce people to work on such useless programs...
 * Think differently...
 *
 * We will release the original code once your deadline is over... :-)
 * Until then enjoy the summer :-)
 */

/* $ABUSE.Code: t-realloc.c,v 1.0 2007/07/02 16:18:43 ABUSE Exp $ */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

float **stations_freqs;
int *n_freqs;
int station_num;

/* Check all frequencies as follows :
 * Create a new array. Any frequency that did not
 * match is qualified to enter that array. This is
 * called straight insertion. We simply keep the new
 * size of that array and realloc() it later.
 * Make sure to free() the old array before assigning the
 * new address to it.
 */
void check (void)
{
int i, c, s, x, n_f;
float freq, *freqs, *p;

for (i = 0; i < station_num; i++)
{
if (i + 1 == station_num)
break;

for (c = 0; c < n_freqs[i]; c++)
{
freq = stations_freqs[i][c];

/* Speed Hack */
if (!freq)
continue;

for (s = i+1; s < station_num; s++)
{
n_f = 0;
freqs = (float *)malloc(n_freqs[s] * sizeof(float));
memset(freqs, 0, n_freqs[s] * sizeof(float));

for (x = 0; x < n_freqs[s]; x++)
{
if (freq != stations_freqs[s][x])
{
freqs[n_f] = stations_freqs[s][x];
n_f++;
}
}

p = (float *)realloc(freqs, n_f * sizeof(float));
free(stations_freqs[s]);
stations_freqs[s] = p;
n_freqs[s] = n_f;
}
}
}
}

int main (void)
{
float freq, *pos;
int i, c, p;

/* Read the number of Stations */
fprintf(stderr, "Type the number of Stations : ");
scanf("%i", &station_num);

n_freqs = (int *)malloc(station_num * sizeof(int));
memset(n_freqs, 0, sizeof(int) * station_num);

stations_freqs = (float **)malloc(station_num * sizeof(float *));
memset(stations_freqs, 0, station_num * sizeof(float *));

/* Now for each station read the number of freqs
* then read each freq.
*/

for (i = 0; i < station_num; i++)
{
fprintf(stderr, "Type the number of frequencies for station %d : ", i);
scanf("%i", &c);
n_freqs[i] = c;

/* Allocate enough space for them */
stations_freqs[i] = (float *)malloc(c*sizeof(float));

/* Read them and place them */
for (p = 0; p < c; p++)
{
fprintf(stderr, "Type the frequency %d for station %d : ", p, i);
scanf("%f", &freq);
stations_freqs[i][p] = freq;
}
}

check();

for (i = 0; i < station_num; i++)
{
if (!n_freqs[i])
continue;

for (c = 0; c < n_freqs[i]; c++)
{
if (stations_freqs[i][c]) /* Sanity Check */
fprintf(stderr, "Station %d can get frequency %f (%d)\n", i, stations_freqs[i][c], c);
}
}

return 0;
}

Quote
Blessed is he who, in the name of charity and good will, shepherds the weak through the Valley of Darkness; for he is truly his brother's keeper, and the finder of lost children.
Ezekiel 25:17
Logged

...America’s cryptologic organization.
anonymous-root
Veteran
Καταστραμμένος
******
Posts: 8574


What do you want to troll today?


View Profile
5η Εργασία-συζήτηση
« Reply #92 on: July 04, 2007, 15:03:04 pm »

@ABUSE θα μπορούσες να γράφεις ελληνικά; Ευχαριστούμε.  Smiley



@ ΠΟΙΟΣ ΣΥΓΧΩΝΕΥΣΕ ΤΑ ΘΕΜΑΤΑ ΤΩΝ ΕΡΓΑΣΙΩΝ????
Logged
SolidSNK
Αbsolute ΤΗΜΜΥ.gr
*******
Gender: Male
Posts: 4617


free()'d and attuned


View Profile
5η Εργασία-συζήτηση
« Reply #93 on: July 04, 2007, 15:46:31 pm »

Quote from: A.B.US.E on July 04, 2007, 14:59:41 pm
Using stderr instead of stdout allows for unbuffered output (thus we use fprintf() instead of printf()). That's an explanation cause some people got really perplexed with this.. Tongue
Y I already got that, u don't have to bang me in teh head...

What I liked most in ur code was the 'speed hack', I knew my code there was sloppy and needed smth like that to minimize the execution time Smiley

Where's ur frustrating 'constant-party' code now anywayz?
Logged

"Savior, conqueror, hero, villain. You are all things, Revan, and yet you are nothing. In the end you belong to neither the light nor the darkness. You will forever stand alone."
^^DaRk_HunTeR
Μόνιμος κάτοικος ΤΗΜΜΥ.gr
******
Gender: Male
Posts: 2149


0001 0010 0100 0010


View Profile
5η Εργασία-συζήτηση
« Reply #94 on: July 04, 2007, 20:12:49 pm »

btw memset()"should have a prototype" is not recognized by my compilers Tongue neither <unistd.h>"unable to open".....borland C++ (and dev C++)
Logged

Without order nothing can exist without chaos nothing can evolve

Timeo hominem unius libri
The minstrel
^^DaRk_HunTeR
Μόνιμος κάτοικος ΤΗΜΜΥ.gr
******
Gender: Male
Posts: 2149


0001 0010 0100 0010


View Profile
5η Εργασία-συζήτηση
« Reply #95 on: July 04, 2007, 20:21:26 pm »

Quote from: anonymous-root on July 04, 2007, 15:03:04 pm
@ABUSE θα μπορούσες να γράφεις ελληνικά; Ευχαριστούμε.  Smiley



@ ΠΟΙΟΣ ΣΥΓΧΩΝΕΥΣΕ ΤΑ ΘΕΜΑΤΑ ΤΩΝ ΕΡΓΑΣΙΩΝ????
οι mods του topic προφανως Tongue
Logged

Without order nothing can exist without chaos nothing can evolve

Timeo hominem unius libri
The minstrel
Καμένος
Μόνιμος κάτοικος ΤΗΜΜΥ.gr
******
Gender: Male
Posts: 2322


View Profile
5η Εργασία-συζήτηση
« Reply #96 on: July 05, 2007, 18:31:27 pm »

Quote from: A.B.US.E on July 04, 2007, 14:59:41 pm
What one should do here is to create a pointer that each of its members will hold memories to other pointers.

Ναί.. κρατάει αναμνήσεις σε άλλους pointers.. Τι το παίζεις αμερικανάκι αφού δε τραβάει??
Logged
Wanderer
Καταστραμμένος
********
Gender: Male
Posts: 5230


Othoum Endron Saous


View Profile
5η Εργασία-συζήτηση
« Reply #97 on: July 06, 2007, 19:54:54 pm »

Αναμνήσεις μιας ζωής...για πάντα καταχωρημένοι...μέσα στη μεταβλητή...ποτέ μή δεσμευμένη Cheesy Grin
Logged

Preserve and keep us safe this night     *and our innocence made fun of justice*

Once we dreamt of everything
united by our love
There's a place for everyone
so we scream "Liberta"
Pages: 1 ... 5 6 [7] Go Up Print
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Scribbles2 | TinyPortal © Bloc | XHTML | CSS
Loading...