누군가 이 코드로 나를 도울 수 있습니까?
이 코드의 출력은 내가 원하는 것이 아닙니다.
암호
포함
 포함
구조체 노드
{
    정수 데이터;
    구조체 노드 *link;
};
구조체 노드 add_at_empty(구조 노드 *head, int 데이터)
{
    구조체 노드 *temp;
    temp= (구조체 노드)malloc(sizeof(구조체 노드));
    임시->데이터=데이터;
    임시->링크=NULL;
    헤드=온도;
    리턴 헤드;
}
구조체 노드 add_at_end(구조 노드 *head, int 데이터)
{
  구조체 노드 *temp1;
  temp1= (구조체 노드)malloc(sizeof(구조체 노드));
  구조체 노드 *ptr=head;
  임시1->데이터=데이터;
  temp1->링크=NULL;
  if(ptr=헤드)
   {
      헤드->링크=temp1;
      ptr=ptr->링크;
   }
  또 다른
   {
      ptr->링크=임시1;
      ptr=임시1;
   }
리턴 헤드;
}
구조체 노드 *print_data(구조 노드 *head)
{
    구조체 노드 *traverse;
    트래버스=헤드;
    동안(트래버스!=NULL)
    {
        std::cout<데이터<<"";
        트래버스=트래버스->링크;
 }
return head;
}
정수 메인()
{
    구조체 노드 헤드=NULL;
    구조체 노드 *curr=NULL;
    정수 노드;
    head=(구조체 노드)malloc(sizeof(구조체 노드));
    curr=(구조체 노드*)malloc(sizeof(구조체 노드));
    std::cout<<"필요한 노드 수 입력"<
    std::cin>>노드;
    std::cout<<"첫번째 노드의 데이터를 입력하세요"<
    std::cin>>head->data;
    head=add_at_empty(헤드, 헤드->데이터);
    노드=노드-1;
 for(int i=0;i<nodes;i++)
 {
     std::cout<<"Enter data of next node "<<std::endl;
     std::cin>>curr->data;
     add_at_end(head, curr->data);
 }
헤드=print_data(헤드);
0을 반환합니다.
}
                
                    
        
    
    
    
    
    
                
                
                
                
                    
                        
                            
                            
                            Reference
                            
                            이 문제에 관하여(누군가 이 코드로 나를 도울 수 있습니까?), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
                                
                                https://dev.to/sourav104k/can-someone-help-me-with-this-code-2le9
                            
                            
                            
                                텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                            
                            
                                
                                
                                 우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)
                            
                            
                        
                    
                
                
                
            
구조체 노드
{
정수 데이터;
구조체 노드 *link;
};
구조체 노드 add_at_empty(구조 노드 *head, int 데이터)
{
구조체 노드 *temp;
temp= (구조체 노드)malloc(sizeof(구조체 노드));
임시->데이터=데이터;
임시->링크=NULL;
헤드=온도;
리턴 헤드;
}
구조체 노드 add_at_end(구조 노드 *head, int 데이터)
{
구조체 노드 *temp1;
temp1= (구조체 노드)malloc(sizeof(구조체 노드));
구조체 노드 *ptr=head;
임시1->데이터=데이터;
temp1->링크=NULL;
if(ptr=헤드)
{
헤드->링크=temp1;
ptr=ptr->링크;
}
또 다른
{
ptr->링크=임시1;
ptr=임시1;
}
리턴 헤드;
}
구조체 노드 *print_data(구조 노드 *head)
{
구조체 노드 *traverse;
트래버스=헤드;
동안(트래버스!=NULL)
{
std::cout<데이터<<"";
트래버스=트래버스->링크;
}
return head;
}
정수 메인()
{
구조체 노드 헤드=NULL;
구조체 노드 *curr=NULL;
정수 노드;
head=(구조체 노드)malloc(sizeof(구조체 노드));
curr=(구조체 노드*)malloc(sizeof(구조체 노드));
std::cout<<"필요한 노드 수 입력"<
std::cin>>노드;
std::cout<<"첫번째 노드의 데이터를 입력하세요"<
std::cin>>head->data;
head=add_at_empty(헤드, 헤드->데이터);
노드=노드-1;
for(int i=0;i<nodes;i++)
 {
     std::cout<<"Enter data of next node "<<std::endl;
     std::cin>>curr->data;
     add_at_end(head, curr->data);
 }
헤드=print_data(헤드);
0을 반환합니다.
}
Reference
이 문제에 관하여(누군가 이 코드로 나를 도울 수 있습니까?), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/sourav104k/can-someone-help-me-with-this-code-2le9텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)