| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2461 人关注过本帖
标题:oj上Compile Error:/judger/run/1d25e9aae7d34931b6127583a460c905/main.c ...
取消只看楼主 加入收藏
浮烟醉
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2019-9-27
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:2 
oj上Compile Error:/judger/run/1d25e9aae7d34931b6127583a460c905/main.c:1:19: fatal
程序代码:
#include<iostream>
using namespace std;
#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 50
#define ERROR -1
typedef int ElementType; 
typedef int Position;
typedef struct LNode *List;
struct LNode {
    ElementType Data[MAXSIZE];
    Position Last;
};

 
/* 初始化 */
List MakeEmpty()
{
    List L;

 
    L = (List)malloc(sizeof(struct LNode));
    L->Last = -1;

 
    return L;
}

 
/* 查找 */


 
Position Find( List L, ElementType X )
{
    Position i = 0;

 
    while( i <= L->Last && L->Data[i]!= X )
        i++;
    if ( i > L->Last )  return ERROR; /* 如果没找到,返回错误信息 */
    else  return i;  /* 找到后返回的是存储位置 */
}

 
/* 插入 */

bool Insert( List L, ElementType X, int i ) 
{ 
    Position j;

 
    if ( L->Last == MAXSIZE-1) {
        /* 表空间已满,不能插入 */
        
        return false; 
    }  
    if ( i<1 || i>L->Last+2 ) { /* 检查插入位置的合法性 */
        
        return false; 
    } 
    for( j=L->Last;j>=i-1;j-- )
        L->Data[j+1] = L->Data[j]; 
    L->Data[i-1] = X;  /* 新元素插入 */
    L->Last++;       /* Last仍指向最后元素 */
    return true; 
} 

 
/* 删除 */
bool Delete( List L, int i )
{
    Position j;

 
    if( i<1 || i>L->Last+1 ) { /* 检查空表及删除位置的合法性 */
        
        return false; 
    }
    for( j=i; j<=L->Last; j++ )
        L->Data[j-1] = L->Data[j]; 
    L->Last--; /* Last仍指向最后元素 */
    return true;   
}
int length(List L)
{
    return L->Last+1;
}
int main(int argc,char** argv){
    List L=MakeEmpty();
    int n,op;
    Position i;
    ElementType x;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&op);
        switch(op)
        {
            case 1:scanf("%d %d",&x,&i);
            Insert(L,x,i);
            break;
            case 2:scanf("%d",&i);
            Delete(L,i);
            break;
            case 3:scanf("%d",&x);
            printf("%d\n",Find(L,x));
            break;
        }
    }
    for(int j=0;j<=L->Last;j++)
    {
        printf("%d ",L->Data[j]);
    }
    return 0;
}
搜索更多相关主题的帖子: Position List int return Data 
2019-09-27 13:11
浮烟醉
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2019-9-27
收藏
得分:0 
CE:/judger/run/1d25e9aae7d34931b6127583a460c905/main.c:1:19: fatal error: iostream: No such file or directory
compilation terminated.

这也不会,那也不会。
2019-09-27 13:13
浮烟醉
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2019-9-27
收藏
得分:0 
回复 3楼 rjsp
谢谢解决了

这也不会,那也不会。
2019-09-27 19:21
快速回复:oj上Compile Error:/judger/run/1d25e9aae7d34931b6127583a460c905/m ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.049767 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved