高分悬赏!!!两个c++程序有何区别???
第一个C写的。#include<stdio.h>#defineMAX_ROW1000#defineMAX_COLUMN1000intmain(intargc,char*a...
第一个C写的。
#include <stdio.h>
#define MAX_ROW 1000
#define MAX_COLUMN 1000
int main(int argc, char * argv[])
{
int case_num;
int case_count;
int seat[MAX_ROW][MAX_COLUMN];
if (EOF == scanf("%d", &case_num))
{
return 1;
}
for (case_count = 0; case_count < case_num; ++case_count)
{
int i;
int j;
int row;
int column;
int r1;
int s1;
int r2;
int s2;
int query_count;
int query_num;
int score;
scanf("%d %d", &row, &column);
for (i = 0; i < row; ++i)
{
for (j = 0; j < column; ++j)
{
scanf("%d", &seat[i][j]);
}
}
scanf("%d", &query_num);
for (query_count = 0; query_count < query_num; ++query_count)
{
scanf("%d %d %d %d", &r1, &s1, &r2, &s2);
score = 0;
for (i = r1 - 1; i < r2; ++i)
{
for (j = s1 - 1; j < s2; ++j)
{
score += seat[i][j];
}
}
printf("Absolutni hodnota pohodlnosti je %d bodu.\n", score);
}
printf("\n");
}
return 0;
}
第二个c++写的。
#include<iostream>
using namespace std;
int seat[1001][1001] ;
int main()
{
int test;
cin >> test;
int i;
for(i = 1; i <= test; ++i)
{ int x1 = 0;
int y1 = 0;
int x2 = 0;
int y2 = 0;
int r = 0;
int s = 0;
cin >> r >> s;
int t = 0;
int j = 0;
for(t = 0; t < r; ++t)
{
for(j = 0; j < s; ++j)
{
cin >> seat[t][j];
}
}
int quary = 0;
cin >> quary;
int k = 0;
for(k = 0; k < quary; k++)
{
int anwser = 0;
cin >> x1 >> y1 >> x2 >> y2;
for(t = y1 - 1; t < y2; ++t)
{
for(j = x1 - 1; j < x2; ++j)
{
anwser += seat[t][j];
}
}
cout << "Absolutni hodnota pohodlnosti je " << anwser << " bodu." << endl;
}
if(i < test)
{
cout << endl;
}
}
return 0;
}以上是北大ACM2215题,第一个能过但第二个就不行为什么????? 展开
#include <stdio.h>
#define MAX_ROW 1000
#define MAX_COLUMN 1000
int main(int argc, char * argv[])
{
int case_num;
int case_count;
int seat[MAX_ROW][MAX_COLUMN];
if (EOF == scanf("%d", &case_num))
{
return 1;
}
for (case_count = 0; case_count < case_num; ++case_count)
{
int i;
int j;
int row;
int column;
int r1;
int s1;
int r2;
int s2;
int query_count;
int query_num;
int score;
scanf("%d %d", &row, &column);
for (i = 0; i < row; ++i)
{
for (j = 0; j < column; ++j)
{
scanf("%d", &seat[i][j]);
}
}
scanf("%d", &query_num);
for (query_count = 0; query_count < query_num; ++query_count)
{
scanf("%d %d %d %d", &r1, &s1, &r2, &s2);
score = 0;
for (i = r1 - 1; i < r2; ++i)
{
for (j = s1 - 1; j < s2; ++j)
{
score += seat[i][j];
}
}
printf("Absolutni hodnota pohodlnosti je %d bodu.\n", score);
}
printf("\n");
}
return 0;
}
第二个c++写的。
#include<iostream>
using namespace std;
int seat[1001][1001] ;
int main()
{
int test;
cin >> test;
int i;
for(i = 1; i <= test; ++i)
{ int x1 = 0;
int y1 = 0;
int x2 = 0;
int y2 = 0;
int r = 0;
int s = 0;
cin >> r >> s;
int t = 0;
int j = 0;
for(t = 0; t < r; ++t)
{
for(j = 0; j < s; ++j)
{
cin >> seat[t][j];
}
}
int quary = 0;
cin >> quary;
int k = 0;
for(k = 0; k < quary; k++)
{
int anwser = 0;
cin >> x1 >> y1 >> x2 >> y2;
for(t = y1 - 1; t < y2; ++t)
{
for(j = x1 - 1; j < x2; ++j)
{
anwser += seat[t][j];
}
}
cout << "Absolutni hodnota pohodlnosti je " << anwser << " bodu." << endl;
}
if(i < test)
{
cout << endl;
}
}
return 0;
}以上是北大ACM2215题,第一个能过但第二个就不行为什么????? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询