▼ กำลังโหลดข้อมูล... ▼
แสดงความคิดเห็น
คุณสามารถแสดงความคิดเห็นกับกระทู้นี้ได้ด้วยการเข้าสู่ระบบ
กระทู้ที่คุณอาจสนใจ
ช่วยอธิบายโค้ดนี้หน่อยครับว่าจะเอาไปพรีหน้าชั้น
import java.util.Scanner;
public class SelectionSort {
void sort (int arr[])
{
&n
สมาชิกหมายเลข 4955521
[Error] Id return 1 exit status C++
#include<stdio.h>
#include<iostream>
using namespace std;
struct record { // Link list
int value;
struct record *next;
};
voi
สมาชิกหมายเลข 5279395
ช่วยด้วยยยยคะ ! มีใครพอช่วยได้ไหมคะ
#include<stdlib.h>
struct node
{
int info;
struct node *link;
}*top = NULL;
void push(int num);
int pop();
void display();
main()
{
int choice,num;
while(1)
{
printf("\n1.Push\n");
printf("2.Pop\n");
printf("3.Display\n");
printf("4.Exit\n\n");
printf("Enter your choice : ");
scanf("%d",&choice);
printf("===============\n\n");
switch(choice)
{
case 1:
printf("Enter your Data : \n");
scanf("%d",&num);
push(num);
break;
case 2:
num = pop();
break;
case 3:
display();
break;
case 4:
exit(1);
default: printf("Invalid Input\n");
}
}
}
void push(int num)
{
struct node *temp;
temp = (struct node *)malloc(sizeof(struct node));
if (temp==NULL)
{
printf("stack overflow\n");
return;
}
temp->info =num;
temp->link =top;
top = temp;
}
int pop()
{
struct node *temp;
int num;
if (top==NULL)
{
printf("stack underflow\n");
return(0);
}
temp =top;
num =top->info;
top =top->link;
free (temp);
printf("Deleted: %d\n",num);
return (num);
}
void display()
{
struct node *p;
if (top==NULL)
{
printf("stack underflow\n");
return;
}
printf("\n stack is\n");
p=top;
while (p!=NULL)
{
printf("%d\n",p->info);
p=p->link;
}
}