本文整理汇总了C++中printList函数的典型用法代码示例。如果您正苦于以下问题:C++ printList函数的具体用法?C++ printList怎么用?C++ printList使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printList函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
int a;
head = NULL;
push( &head, 3);
push( &head, 2);
push( &head, 1);
push( &head, 1);
checkList();
printf("Head Node: \n");
printNode(head);
printf("List: \n");
printList(head);
/* Count Test */
printf("Count of 1 = %d\n", Count( head, 1 ));
/* GetNth test */
printf("Value at node 2 = %d \n", GetNth( head, 2));
scanf("%d",&a);
}
示例2: sort
void Ga::selectSurvive(vector<Individual*> &family) {
sort(family.begin(),family.end(),Individual::Comparator);
m_Population.push_back(family[0]);
Util::removeVector(family,0);
int r=roulette(family);
m_Population.push_back(family[r]);
Util::removeVector(family,r);
for(int i=0; i<family.size(); i++) {
delete(family[i]);
}
#ifdef DEBUG
cout<<"crossover"<<endl;
printList();
#endif
}
示例3: main
int main() {
ListHndl intList;
intList = newList();
int data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
/*
* Integer list testing
*
*/
printHeading(" INTEGER LIST ", '#', 80);
printList(stdout, intList);
accessorTest("isEmpty", 1, isEmpty(intList));
for(int i = 0; i < 10; i++) {
insertAtFront(intList, data[i]);
mutatorTest("%s : data = %d", "insertAtFront", data[i]);
}
moveFirst(intList);
for(int i = 0; i < 5; i++) {
printList(stdout, intList);
insertBeforeCurrent(intList, data[i]);
mutatorTest("insertBeforeCurrent : data = %d", data[i]);
moveNext(intList);
}
accessorTest("isEmpty", 0, isEmpty(intList));
printList(stdout, intList);
moveFirst(intList);
while( !offEnd(intList) ) {
printList(stdout, intList);
moveNext(intList);
}
moveLast(intList);
while( !offEnd(intList) ) {
printList(stdout, intList);
movePrev(intList);
}
makeEmpty(intList);
mutatorTest("makeEmpty( intList)");
printList(stdout, intList);
accessorTest("isEmpty", 1, isEmpty(intList));
freeList(intList);
return 0;
}
示例4: main
int main(){
node* head = NULL;
push(&head, 10);
push(&head, 4);
push(&head, 15);
push(&head, 20);
push(&head, 50);
/* Create a loop for testing */
head->next->next->next->next->next = head->next->next;
detectAndRemoveLoop(head);
printf("Linked List after removing loop \n");
printList(head);
return 0;
}
开发者ID:linearregression,项目名称:geeksforgeeks,代码行数:18,代码来源:25.detect-and-remove-loop-in-a-linked-list.cpp
示例5: printGraph
void printGraph ( FILE* out, Graph G )
{
if ( G == NULL )
{
printf ( "Graph Error: printGraph() on NULL graph" );
exit(1);
}
int x;
for( x = 1; x <= getOrder(G); x++)
{
fprintf(out, "%d: ", x);
printList ( out, G->adjacency[x] );
fprintf(out, "\n");
}
}
示例6: main
// insert proper tests here
int main (int argc, const char * argv[]) {
int start,end;
printf("input start and end\n");
scanf("%d %d",&start,&end);
link list = fromTo (start, end);
printList (list);
printf("The sum is %d.\n",sumListItems(list));
dlink doublelist = doublify(list);
printDList(doublelist);
freeList(list);
freeDList(doublelist);
return 0;
}
示例7: shellsort3
void shellsort3(int *a, int n)
{
int i, j, gap;
for (gap = n / 2; gap > 0; gap /= 2)
{
printf("gap = %d\n", gap);
for (i = gap; i < n; i++)
{
for (j = i - gap; j >= 0 && a[j] > a[j + gap]; j -= gap)
{
DataSwap(&a[j - 1], &a[j]);
printDataSwap('i', i, 'j', j);
printList(a, n);
}
}
}
}
示例8: printGraph
void printGraph(GraphRef g){
for(int i=0; i<g->numVertices; i++){
printf("Node %d:\n", i);
if(i!=0){
printf("Parent ");
printList(g->parent[i]);
}
printf("\tColor %d, Dist %d", g->color[i], g->distance[i]);
printf("\tEdges:");
ListRef index = g->vertices[i];
moveFirst(index);
while(!offEnd(index)){
printf("%d, ",getCurrent(index));
moveNext(index);
}
}
}
示例9: main
int main(){
int i=0;
char name[50];
int roll_no;
node *first=NULL;
for(i=0;i<5;i++){
printf("Enter Name:");
readline(name,50);
printf("Enter Roll No:");
scanf("%d",&roll_no);
// first=addToBegining(first,name,roll_no);
first=addToEnd(first,name,roll_no);
}
printList(first);
}
示例10: main
int main() {
int a[N], b[N], i;
for (i = 0; i< N; i++) {
a[i] = i;
b[i] = 0;
}
veccpy(a, b, N);
if (memcmp(a, b, N * sizeof (int)) != 0) {
printList((int *)a, (int *)b, N);
printf ("Vector copy C case - Failed \n");
} else {
printf ("Vector copy C case - Passed \n");
}
return 0;
}
示例11: main
int main()
{
struct ListNode * t1[4];
for(int i = 0; i< 4; i++){
t1[i] = malloc(sizeof(struct ListNode));
}
t1[0]->val = 1;
t1[1]->val = 2;
t1[2]->val = 2;
t1[3]->val = 5;
t1[0]->next = t1[1];
t1[1]->next = t1[2];
t1[2]->next = t1[3];
t1[3]->next = NULL;
struct ListNode * hhh = deleteDuplicates(t1[0]);
printList(hhh);
}
示例12: output
void Function::outputFile(string filename)
{
ofstream output(filename);
if (output.is_open() == true)
{
output << "var code = {\"type\":\"function\", \"code\":\"";
output << addBackslashes(statements.statement);
output << "\", \"inner\":[";
output << printList(statements.children);
output << "]};";
output.close();
}
else
{
//error
}
}
示例13: inputCommand
static void inputCommand(void)
{
char command[20];
printf("Type 'help' to see help\n\n");
while (true) {
fgets(command, 20, stdin);
if (command[strlen(command) - 1] == '\n') {
command[strlen(command) - 1] = '\0';
}
if (_stricmp(command, "about") == 0) {
printAbout();
} else if (_stricmp(command, "help") == 0) {
printHelp();
} else if (_stricmp(command, "log on") == 0) {
g_RPCServer.SetLogOn(true);
} else if (_stricmp(command, "log off") == 0) {
g_RPCServer.SetLogOn(false);
} else if (_stricmp(command, "list") == 0) {
printList();
} else if (_stricmp(command, "quit") == 0) {
if (g_MountProg.GetMountNumber() == 0) {
break;
} else {
printConfirmQuit();
fgets(command, 20, stdin);
if (command[0] == 'y' || command[0] == 'Y') {
break;
}
}
} else if (_stricmp(command, "refresh") == 0) {
g_MountProg.Refresh();
} else if (_stricmp(command, "reset") == 0) {
g_RPCServer.Set(PROG_NFS, NULL);
} else if (strcmp(command, "") != 0) {
printf("Unknown command: '%s'\n", command);
printf("Type 'help' to see help\n");
}
}
}
示例14: main
void main(void)
{
int i = 1;
int x = 0;
List1Element * head = createList();
intro();
scanf ("%d", &i);
while (i)
{
switch (i)
{
//case 0:
// delList(head);
// break;
case 1 :
printf("enter the value\n");
scanf("%d", &x);
insertEl (head, x);
break;
case 2 :
if (isEmpty(head))
printf("sorry it seems to be nothing here\n");
else
printf("%d\n", getMin(head));
break;
case 3:
if (isEmpty(head))
printf("sorry it seems to be nothing here\n");
else
printList(head);
printf("\n");
break;
default:
printf("no no no, you're doing it wrong!\n");
}
if (i)
{
intro();
scanf ("%d", &i);
}
}
delList(head);
delete head;
}
示例15: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
printf("0 - exit\n");
printf("1 - add value to sorted list\n");
printf("2 - remove value from list\n");
printf("3 - print list\n");
IntList *head = newList(-1);
while(true)
{
printf("Input command:\n");
int command = 0;
scanf("%d", &command);
int val = 0;
switch (command)
{
case 0:
deleteList(head);
return 0;
case 1:
printf("Input value:\n");
scanf("%d", &val);
addToSortedList(head, val);
break;
case 2:
printf("Input value:\n");
scanf("%d", &val);
removeValue(head, val);
break;
case 3:
printList(head);
break;
};
}
deleteList(head);
scanf("%*s");
return 0;
}