1 Commits
07_02 ... 07_01

Author SHA1 Message Date
unlockable
45caedbfa7 判题失败了? 2023-12-10 23:58:39 +08:00

View File

@@ -1,11 +1,10 @@
#include <math.h>
#include <stdio.h> #include <stdio.h>
int p = 0; int p = 0;
int m = 0, n = 0; int m = 0, n = 0;
double A[5][10000], Z[10000]; double A[5][10000] = {0}, Z[10000] = {0};
double get_content(int row, int column) { double get_content(int row, int column) {
if (abs(row - column) > p / 2) { if (row - column > 2 || row - column < -2) {
return 0; return 0;
} }
if (row < 0 || row >= n) { if (row < 0 || row >= n) {
@@ -14,11 +13,11 @@ double get_content(int row, int column) {
if (column < 0 || column >= n) { if (column < 0 || column >= n) {
return 0; return 0;
} }
return A[(row - column + p / 2)][column]; return A[(row - column + 2)][column];
} }
int set_content(int row, int column, double val) { int set_content(int row, int column, double val) {
if (abs(row - column) > p / 2) { if (row - column > 2 || row - column < -2) {
return 0; return 0;
} }
if (row < 0 || row >= n) { if (row < 0 || row >= n) {
@@ -27,24 +26,24 @@ int set_content(int row, int column, double val) {
if (column < 0 || column >= n) { if (column < 0 || column >= n) {
return 0; return 0;
} }
A[(row - column + p / 2)][column] = val; A[(row - column + 2)][column] = val;
return 0; return 0;
} }
// int output() { int output() {
// for (int i = 0; i < p; i++) { for (int i = 0; i < p; i++) {
// for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
// printf("%lf ", get_content(i, j)); printf("%lf ", get_content(i, j));
// } }
// printf("\n"); printf("\n");
// } }
// printf("\n"); printf("\n");
// return 0; return 0;
// } }
int outputZ() { int outputZ() {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
printf("%.4lf ", Z[i]); printf("%lf ", Z[i]);
} }
printf("\n"); printf("\n");
return 0; return 0;
@@ -53,13 +52,23 @@ int outputZ() {
int main() { int main() {
scanf("%d", &p); scanf("%d", &p);
scanf("%d %d", &n, &m); scanf("%d %d", &n, &m);
for (int i = 0; i < p / 2; i++) { // for (int i = 0; i < p / 2; i++) {
for (int j = p / 2 - i; j < n; j++) { // for (int j = p / 2 - i; j < n; j++) {
// scanf("%lf", &A[i][j]);
// }
// }
// for (int i = p / 2; i < p; i++) {
// for (int j = 0; j < n - (i - p / 2); j++) {
// scanf("%lf", &A[i][j]);
// }
// }
for (int i = 2 - p / 2; i <= 2; i++) {
for (int j = 2 - i; j < n; j++) {
scanf("%lf", &A[i][j]); scanf("%lf", &A[i][j]);
} }
} }
for (int i = p / 2; i < p; i++) { for (int i = 3; i <= 2 + p / 2; i++) {
for (int j = 0; j < n - (i - p / 2); j++) { for (int j = 0; j < n - (i - 2); j++) {
scanf("%lf", &A[i][j]); scanf("%lf", &A[i][j]);
} }
} }
@@ -75,7 +84,7 @@ int main() {
if (base != 0) { if (base != 0) {
double coefficient = base / diag_elem; double coefficient = base / diag_elem;
set_content(row, col, -coefficient); set_content(row, col, -coefficient);
for (int l = col + 1; l < col + 3; l++) { for (int l = col + 1; l < n; l++) {
set_content(row, l, get_content(row, l) - coefficient * get_content(col, l)); set_content(row, l, get_content(row, l) - coefficient * get_content(col, l));
} }
} }
@@ -140,11 +149,10 @@ int main() {
// outputZ(); // outputZ();
// output // output
// for (int j = 0; j < n; j++) { for (int j = 0; j < n; j++) {
// printf("%.4lf ", Z[j]); printf("%.4lf ", Z[j]);
// } }
// printf("\n"); printf("\n");
outputZ();
} }
return 0; return 0;
} }