hdu1073Online Judge
#include <iostream>
using namespace std;
#define N 256
#define M 5010
char source[M];
char dist[M];
int m_hash[N];
int main()
{
int i, n, t;
char tmpstr[N];
while(scanf("%d", &t) != EOF)
{
while(t--)
{
getchar();
memset(m_hash, 0, sizeof(m_hash));
gets(source);
while(gets(source) && strcmp(source, "END"))
{
n = strlen(source);
if (!n)
{
++m_hash[(unsigned char)'\n'];
continue;
}
for(i = 0;i < n;++i)
{
++m_hash[(unsigned char)source[i]];
}
}
gets(source);
while(gets(source) && strcmp(source, "END"))
{
n = strlen(source);
if (!n)
{
--m_hash[(unsigned char)'\n'];
continue;
}
for(i = 0;i < n;++i)
{
--m_hash[(unsigned char)source[i]];
}
}
bool Presentation = false;
for(i = 0;i < N; ++i)
{
if (m_hash[i] != 0)
{
if (i == (unsigned char)' ' || i == (unsigned char)'\t' || i == (unsigned char)'\n')
{
Presentation = true;
continue;
}
break;
}
}
if (i == N)
{
if (Presentation == false)
{
printf("Accepted\n");
}
else
{
printf("Presentation Error\n");
}
}
else
{
printf("Wrong Answer\n");
}
}
}
return 0;
}
hdu1200To and Fro
#include <iostream>
using namespace std;
#define N 110
#define M 20
char m_hash[N][M];
int main()
{
int c, r, i, j, flag, n;
char str[2*N];
while(scanf("%d", &c) != EOF && c)
{
scanf("%s", str);
n = strlen(str);
r = n / c;
for (i = 0;i < r; ++i)
{
if (i %2 == 0)
{
for (j = 0; j < c; ++j)
{
m_hash[i][j] = str[i * c + j];
}
}
else
{
for (j = c - 1; j >= 0; --j)
{
m_hash[i][c - j - 1] = str[i * c + j];
}
}
}
for (i = 0;i < c; ++i)
{
for (j = 0; j < r; ++j)
{
printf("%c", m_hash[j][i]);
}
}
printf("\n");
}
return 0;
}
hdu1321Reverse Text
#include <iostream>
using namespace std;
#define N 100
char str[N];
void Reverse(char str[])
{
int n = strlen(str), i, j;
char tmp;
for (i = 0, j = n - 1; i <= j ; ++i, --j)
{
tmp = str[i];
str[i] = str[j];
str[j] = tmp;
}
}
int main()
{
int t;
while(scanf("%d", &t) != EOF)
{
getchar();
while(t--)
{
gets(str);
Reverse(str);
printf("%s\n", str);
}
}
return 0;
}

1175

被折叠的 条评论
为什么被折叠?



