C / C++ Code Portfolio


if (*current < *nextCurrent) { float



Download 112,15 Kb.
bet5/30
Sana01.03.2022
Hajmi112,15 Kb.
#475852
1   2   3   4   5   6   7   8   9   ...   30
Bog'liq
dddd

if (*current < *nextCurrent)
{
float temp = *current;
*current = *nextCurrent;
*nextCurrent = temp;
didSwap = true;
}
}
// don't check the bubbled value
--last;
} while (didSwap);
// return the location of the start of the sorted array
return first;
}
Memory Handling
// This function swaps the values of two objects given two pointers pointing to the two objects

#include


#include
#include

void SwapObjects(void *pa, void *pb, size_t size)
{
// declare a temporary pointer that will be used for the object swap
void *vp;
// allocate enough bytes to hold one object, for temporary storage (exit program if unable teo allocate)
if ((vp = malloc(size)) == NULL)
{
fputs("Could not allocate memory\n", stderr);
exit(EXIT_FAILURE);
}
// copy the object stored at *pb to *vp
memcpy(vp, pb, size);
// copy the object stored at *pa to *pb
memcpy(pb, pa, size);
// copy the object stored at *vp to *pa. this completes the swap
memcpy(pa, vp, size);
// free the temporary storage
free(vp);
}
// This file contains the following functions:
// Create2D() creates a 2-dimensional pointer array of data type Type having "rows" rows and "cols" columns.
// Free2d() frees memory pointed to by its argument
// SafeMalloc() attempts to allocate memory, and outputs an error to stderr and exits if allocation fails

#include


#include
#include "C2A5E2_Type-Driver.h"

static void *SafeMalloc(size_t memSize)
{
void *vp;
// Attempt to allocate memory. If allocation fails, output error to stderr and exit
if ((vp = malloc(memSize)) == NULL)
{
fputs("Could not allocate memory\n", stderr);

Download 112,15 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   30




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish