C / C++ Code Portfolio



Download 112,15 Kb.
bet25/30
Sana01.03.2022
Hajmi112,15 Kb.
#475852
1   ...   22   23   24   25   26   27   28   29   30
Bog'liq
dddd

catch (...)
{
clog << "vectorTest FAILED: exception thrown during partition() or sort()\n";
}
try
{
// declare an ostringstream buffer
ostringstream buff;
// declare an ostream_interator using the buffer
ostream_iterator output(buff);
// copy the vector into the ostringstream buffer
copy(ints.begin(), ints.end(), output);
if (buff.str() == "24681013579")
{
clog << "vectorTest PASSED\n";
}
else
{
clog << "vectorTest FAILED: Contents were not copied to ostream buffer\n";
}
}
catch (...)
{
clog << "vectorTest FAILED: exception thrown during copy() operation\n";
}
}

int main()
{
// call all of the unit tests
dequeTest();
stringTest();
vectorTest();
}
Example: Linked List
// This file contains the following functions:
// SafeMalloc() - safely allocates memory; causes the program to exit if allocation fails
// CreateListNode() - creates a new node and initializes its members
// Insert() - inserts a node into a linked list
// CreateList() - creates a singly-linked list from strings it reads from a text file. Each list node
// represents a unique string and the number of times it occurs in the file
// PrintList() - prints each string and the number of times it occurs in the file to the console
// FreeList() - frees the string members of each node, then frees every node.

#include


#include
#include
#include "C2A6E4_List-Driver.h"

// maximum string size we will consider


#define MAX_STRING_LENGTH 256

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   ...   22   23   24   25   26   27   28   29   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