求求大佬看看哪错了
查看原帖
求求大佬看看哪错了
704882
KQYaili楼主2022/4/22 13:16
#include<cstring>
#include<bits/stdc++.h>
using namespace std;

int main() {
	
	int i,top=0;
	char s[100];
	int j,a[26]={0};
	for (i = 0; i < 4; i++) {
		gets_s(s);//录入
		for (j = 0; j < strlen(s); j++) {
			if(s[j]>='A'&&a[j]<='Z')
			a[s[j]-'A']++;//记录每一列数据
		}	
	}
	for (i = 0; i < 26; i++) {
		if (top < a[i]) top = a[i];//找出最大行数
	}
	char** pps8Output = (char**)malloc(top * sizeof(char*));//动态二维字符数组

	///< malloc
	for (i = 0; i < top; i++)
	{
		pps8Output[i] = (char*)malloc(26 * sizeof(char));
	}

	for (i = 0; i < top; i++) {
		for (j = 0; j < 26; j++) pps8Output[i][j] = ' ';//初始化
	}
	for (i = 0; i < 26; i++) {
		for (j = 1; j <= a[i]; j++) {
			pps8Output[top - j][i] = '*';//数据录入
		}

	}
	for (i = 0; i < top; i++) {
		for (j = 0; j < 26; j++) printf("%c ", pps8Output[i][j]);//打印表
		printf("\n");
	}
		
	for (i = 0; i < 26; i++) printf("%c ", 'A' + i);
}
2022/4/22 13:16
加载中...