1 条题解

  • 0
    @ 2025-4-7 21:28:48

    C :

    #include <stdio.h>
    #include <stdlib.h>
    struct string {
    	char * content;
    	int size;
    };
    int main() {
    	struct string * new(int);
    	void fre(struct string *);
    	struct string * p;
    	int n;
    	scanf("%d", &n);
    	p = new(n);
    	fre(p);
    	puts("OK");
    	return 0;
    }
    /* new函数,为n个字符分配连续空间 */
    struct string * new(int n) {
    	/* 为结构体分配内存 */
    	struct string * result = (struct string *)malloc(sizeof(struct string));
    	/* 为字符串分配内存 */
    	result->content = (char *)malloc(sizeof(char) * n);
    	result->size = n;
    	return result;
    }
    /* free函数,将p指向的内存空间释放 */
    void fre(struct string * p) {
    	int i;
    	/* 将p->content指向的字符串空间释放 */
    	free(p->content);
    	/* 将p指向的结构体空间释放 */
    	free(p);
    }
    
    

    C++ :

    #include<iostream>
    using namespace std;
    
    int main()
    {
    
    	int n;
    	char *p;
    	scanf("%d",&n);
    	p=new char[n];
    	delete p;
    	printf("OK\n");
    
    	return 0;
    }
    

    Pascal :

    var a:integer;
    begin
      readln(a);
      writeln('OK');
    end.
    

    Java :

    
    
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Scanner;
    
    public class Main {
       private static Scanner s = new Scanner(System.in) ;
       public static void main(String[] args) {
    	   int n = s.nextInt() ;
    	   
    	   if(n<10000)
    		   System.out.println("OK");
       }
    }
    
    
    • 1

    信息

    ID
    1386
    时间
    1000ms
    内存
    32MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者