#include <stdio.h> #define maxsize 5000 char buf[maxsize]; char *head = buf; char *new(int size) { //分配元素字长 //可用内存分配完毕 if (maxsize - (buf - head) < size) return 0; head += size; return head - size; } int *arr; int *arr2; char *str; int main() { arr = new(3 * sizeof(int)); arr2 = new(3 * sizeof(int)); str = new(10 * sizeof(char)); for (int i=0;i<3;i++) scanf("%d",&arr[i]); for (int i=0;i<3;i++) scanf("%d",&arr2[i]); scanf("%s",str); for (int i=0;i<6;i++) printf("%d\n",arr[i]); printf("%s\n",str); }
时间: 2024-10-11 07:15:22