我遇到一个问题:
Given a matrix of size n x m with type of date strings of characters.
Make a program who print the string of maximum lenght from every line of matrix.
我做了一些事情,但是当我尝试执行时它不起作用。 我不知道为什么。有人可以给我一些建议吗?
#include <stdio.h>
#include <stdlib.h>
int main()
{
char tab[50][255];
int m, n, i, j;
printf("\n Dati numarul de linii : ");
scanf("%d", &m);
printf("\n Dati numarul de coloane : ");
scanf("%d", &n);
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
printf("\n Elementul [%d][%d] de tip sir de caractere : ", i+1, j+1);
scanf("%s", tab[50][255]);
}
}
return 0;
}
最佳答案
char tab[50][5][255];
int m, n, i, j;
printf("\n Dati numarul de linii : ");
scanf("%d", &m);
printf("\n Dati numarul de coloane : ");
scanf("%d", &n);
for(i=0; i<m; i++)
{
for(j=0; j<n; j++)
{
printf("\n Elementul [%d][%d] de tip sir de caractere : ", i+1, j+1);
scanf("%s", tab[i][j]);
}
}
关于C 字符串矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21503378/