#include <iostream> #include <fstream> #include<stdlib.h> #define MAXNUM 200 int Isood(int n); using namespace std; int main(void) { int n; cout<<"input n:"; cin>>n; int *p; p=(int *)malloc(n*sizeof(int)); for(int i=0;i<n;i++) { p[i]=i; } for(int i=0;i<n;i++) { cout<<p[i]<<" "; } free(p); }
main(){ struct stu{ int num; char *name; char sex; float score; } *ps; ps=(struct stu*)malloc(sizeof(struct stu)); ps->num=102; ps->name="Zhang ping"; ps->sex='M'; ps->score=62.5; printf("Number=%d\nName=%s\n",ps->num,ps->name); printf("Sex=%c\nScore=%f\n",ps->sex,ps->score); free(ps); }