在c++中?如何对动态数组赋值 比如说要求输入 n个学生的成绩。怎么做

[复制链接]
查看11 | 回复2 | 2011-3-24 22:58:58 | 显示全部楼层 |阅读模式
如果这n个学生数只由你输入的结果来定,也就是说,不直接输入n,怎么办啊?

回复

使用道具 举报

千问 | 2011-3-24 22:58:58 | 显示全部楼层
用vectorvector student;int n;int num;cin>>n;num=1;for(i=1;i>num;student.pushback(num);num++;}这样student[0]=1;~~~~~student[n-1]=n;
回复

使用道具 举报

千问 | 2011-3-24 22:58:58 | 显示全部楼层
;scanf("%d",&n)p=(int *)malloc(n*sizeof(int));for(i=0;i>n;int a*=new int [n];for(int i=0;i>a;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行