C / C++ Code Portfolio


if (*(ptr + ptrIndex) == value



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

if (*(ptr + ptrIndex) == value)
{
return(ptr + ptrIndex);
}
}
return(NULL);
}
// This function computes the average element value for a 4-D array using two methods. The first method
// accesses the elements of the array using 4 nested for loops and 4-D indexing. The second method
// accesses the elements of the array using linear compact pointer notation.

#include "C2A4E1_ArraySize.h"



void ComputeAverages(float (*anArray)[DIM1][DIM2][DIM3], float *nestedAvg, float *linearAvg)
{
float subTotal = 0;
// access the elements using 4 nested for loops and 4-d indexing
for (int index0 = 0; index0 < DIM0; ++index0)
for (int index1 = 0; index1 < DIM1; ++index1)
for (int index2 = 0; index2 < DIM2; ++index2)
for (int index3 = 0; index3 < DIM3; ++index3)
subTotal += anArray[index0][index1][index2][index3];
*nestedAvg = subTotal / Elements4D;
subTotal = 0;
// access the elements using compact pointer notation
for (float *ptr = (float *)anArray; ptr < (float *)anArray + DIM0 * DIM1 * DIM2 * DIM3; ++ptr)
subTotal += *ptr;
*linearAvg = subTotal / Elements4D;
}
// This function sorts values in an array in descending order using a bubble sort algorithm

#include



float *SortValues(float *first, size_t elements)
{
// store the location of the last element array
float *last = &first[elements - 1];
// the bubble sort algorithm
bool didSwap;
do
{
didSwap = false;
// for each non-bubbled element of the array
for (float *current = first, *nextCurrent = current + 1; current < last; ++current, ++nextCurrent)
{
// if the current array value is less than the next array value, swap them

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