zoukankan      html  css  js  c++  java
  • [Error] 'for' loop initial declarations are only allowed in C99 or C11 mode

    #include <stdio.h>
    #include <stdlib.h>
    #define LIST_INIT_SIZE 100 //线性表存储空间的初始分配量
    #define LISTINCREMENT 10   //线性表存储空间的分配增量(当存储空间不够时要用到)
    typedef int ElemType;      //数据元素的类型,假设是int型的
    typedef struct {
    	ElemType *elem;       //存储空间的基地址
    	int length;      //当前线性表的长度
    	int listsize;    //当前分配的存储容量
    } SqList;
    int main() {
    	SqList list;
    	InitList(list);
    
    	int n = 10;
    
    	//添加10个数字给线性表list
    	for (int i = 0; i < 10; i++) {
    		ListInsert(list, i+1, i+1);
    	}
    	//删除第5个
    	ElemType e;
    	ListDelete(list, 5, e);
    	printf("删除的元素是:%d
    ", e);
    
    	//在第2个位置插入一个元素-1
    	ListInsert(list, 2, -1);
    
    	//输出线性表
    	for ( i = 0; i < 10; i++) {
    		printf("%d ", list.elem[i]);
    	}
    	//输出结果是:1 -1 2 3 4 6 7 8 9 10
    
    	system("pause");
    }
    

      

  • 相关阅读:
    Java绘出pdf实现方法
    Java设置字体颜色
    猜测分箱算法
    获取图片存储到本地
    input(file)异步上传文件
    物流轨迹抓取
    bootstrap 模态框
    从数组中随机选择一个数
    spring cron表达式
    mabtis批量修改
  • 原文地址:https://www.cnblogs.com/rsapaper/p/10290662.html
Copyright © 2011-2022 走看看