标题:高手们,能不能帮我看看我的code问题在哪里呢,谢谢
取消只看楼主
weiwei859
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-5-12
结帖率:50%
 问题点数:0 回复次数:4 
高手们,能不能帮我看看我的code问题在哪里呢,谢谢
#include <iostream>

using std::cout;
using std::cin;
using std::endl;
// contains function prototypes for functions srand and rand
#include <cstdlib>
#include <ctime>   // contains prototype for function time
  // function prototype
int main()
{
   int m;
   int n;
   cout<<"please input the number of row"<<endl;
   cin>> m ;
   cout<<"please input the number of column"<<endl;
   cin>> n ;
      int* A=new int [m+n][m*n];
   //generate the A matrix//
   for (int i=0;i<m;i++) for (int j=0;j<n;j++) A[i][n*i+j]=1;
   for (int i=0;i<n;i++) for (int j=0;j<m;j++) A[m+i][n*j+i]=1;
   //Print A matrix for test//
   for (int i=0;i<(m+n);i++)
   {
       for (int j=0;j<m*n;j++) cout<<A[i][j]<<" ";
       cout<<endl;
   }


   delete [] rowsum;
   delete [] colsum;
   return 0;  // indicates successful termination
} // end main



[ 本帖最后由 weiwei859 于 2011-5-12 11:21 编辑 ]
搜索更多相关主题的帖子: function 
2011-05-12 06:39
weiwei859
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-5-12
得分:0 
那要怎么改呢。我在网上找到了要用new,但是不知道为什么还是不可以
2011-05-12 07:14
weiwei859
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-5-12
得分:0 
但是如果我不是外部输入的,怎么赋值呢


[ 本帖最后由 weiwei859 于 2011-5-12 10:56 编辑 ]
2011-05-12 08:50
weiwei859
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-5-12
得分:0 
但是我的code为什么跑出来有问题呢。
int* A=new int [m+n][m*n];
   int* B=new int [m+n];
   //generate the A matrix//
   for (int i=0;i<m;i++) for (int j=0;j<n;j++) A[i][n*i+j]=1;
   for (int i=0;i<n;i++) for (int j=0;j<m;j++) A[m+i][n*j+i]=1;
问题主要在于array
2011-05-12 11:20
weiwei859
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2011-5-12
得分:0 
谢谢,大家太好了,很有帮助。
2011-05-14 11:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-339564-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.477425 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved