acm runtime error

来源:百度知道 编辑:UC知道 时间:2024/06/01 03:37:05
Description

在战争时期,各个国家都要保证军队的行动保密性,所以在信息传达时会采取各种加密方法。有一天,A国安全局成员Oo(也就是传说中的ZSL),发明了一种对指令的加密方法。具体操作如下,取两个正整数X、Y,对于一段明文字符串,将其按行填入一个X行Y列的矩阵中(非字母不填、而且所有字母要求权转换为大写),若未填满,则按字母表顺序顺次填充(’A’…’Z’循环填充)。比如对于X=3,Y=3,明文为”Problem”时,矩阵填充后的结果为:
PRO
BLE
MAB
这样,Oo就得到了一个矩阵,将他按列输出就得到了Oo所要的的密文“PBMRLAOEB”。由于A国编程人员奇缺。所以Oo向你求助,希望你能够帮助他写一个加密程序,从而使得对于任意给定的X、Y以及明文,程序都能输出正确的密文。

Input

第一行X,Y(0 < X <= 200,0 < Y <= 200)。
第二行至末尾每行均为一个明文(保证明文中字母的个数N <= X*Y)。

Output

对于每一行明文输出对应的一行密文。

Sample Input

3 3
Problem
t e s t
l I 156-*/- S t
u 45/-90 N I v \908() 8768 *er #!@$& S a L

Sample Output

PBMRLAOEB
TTCEADSBE
LTCIADSBE
UVSNEAIRL

各位大牛看看我的算法的额。。。。。。
#include<stdio.h>
char b[300][300];
int main()
{
char a,m;
int x,y,i,j;
while(scanf("%d%d\n",&x,&y)!=EOF)
{<

好了,AC了.

User Name: porker2008
Run ID: 18545
Problem: 1015
Result: Accepted
Language: GCC
Time Used: 32 ms
Memory Used: 796 KB
Code Length: 768 Bytes
Time Submit: 2009-07-16 15:43:00

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <malloc.h>

int main()
{
int X,Y,k,i,j;
scanf("%d%d",&X,&Y);
char** temp = (char**)malloc(X*sizeof(char*));
for(i=0;i<X;i++) temp[i] = (char*)malloc(Y*sizeof(char));
char t;
getchar();
while(1)
{
k = 0;
char s = 'A';
for(i=0;i<X;i++)
for(j=0;j<Y;j++)
{
if(!k) if(scanf("%c",&t)!=1) return 0;
while(t!=10&&!isalpha(t)) {if(scanf("%c",&t)!=1) return 0;}
if(t==10) k = 1;
if(k)
{
temp[i][j] = s;
s++;
if(s>'Z') s='