Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,因此它是on-topic,用于堆栈溢出。
                        
                        5年前关闭。
                                                                                            
                
        
我正在Visual Studio中执行以下程序。

// practice1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "conio.h"
void addition();
void display(int a[][10],int row, int column);
int _tmain(int argc, _TCHAR* argv[])

{
    addition();
    getch();
    return 0;
}
void addition()
{
    int a[10][10],b[10][10],m,n,k=0,j;
    printf("Enter order of matrix\n");
    //scanf("%d%d",&m,&n);
    m=2;n=3;
    printf("Enter matrix elements of matrix A\n");
    for(k=1;k<m;k++);
    {
        for(j=0;j<n;j++)
        {
            scanf("%d",&a[k][j]);
        }
    }
    printf("Enter matrix elements of matrix B\n");
    for(k=0;k<m;k++)
    {
        for(j=0;j<n;j++)
        {
            scanf("%d",&b[k][j]);
        }
    }
    //display(a,m,n);
    printf("\n");
    //display(b,m,n);
}




//void display(int a[][10],int row, int column)
//{
//  int i,j;
//  for(i=0;i<row;i++)
//  {
//      for(j=0;j<column;j++)
//      {
//          printf("%d",a[i][j]);
//      }
//      printf("\n");
//  }
//}


在“第一循环”中,当控制进入循环时,k的值自动设置为2。
图片附上。 --

最佳答案

设置断点的行上有一个错字。

该值为2,因为您已经退出循环。

删除分号,然后重试。

关于c - for循环初始化程序不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23181610/

10-11 23:10
查看更多