#2 |
´ÙÀ½°ú °°ÀÌ 0ÀÌ ¾Æ´Ñ ¿ä¼Òµé¸¸À» ³ªÅ¸³»´Â ¹æ¹ýÀ¸·Î Ç¥ÇöµÈ µÎ °³ÀÇ Çà·ÄÀ»
¹è¿ÀÇ Àüü ¿ä¼Ò¸¦ Ç¥ÇöÇÏ´Â Çà·Ä·Î º¯È¯ÇÏ°í º¯È¯µÈ Çà·ÄÀ» °öÇؼ Ãâ·ÂÇÏ´Â ÇÁ·Î±×·¥À»
ÀÛ¼ºÇÏ¿© Á¦ÃâÇϽÿÀ.
#include <stdio.h>
#define MAX_TERMS 100
typedef struct {
int row;
int col;
int value;
} element;
typedef struct SparseMatrix {
element data[MAX_TERMS];
int rows; // ÇàÀÇ °³¼ö
int cols; // ¿ÀÇ °³¼ö
int terms; // Ç×ÀÇ °³¼ö
} SparseMatrix;
SparseMatrix x1 = { {{1,1,5},{2,2,9}}, 3, 3, 2};
SparseMatrix y1 = { {{0,0,5},{2,2,9}}, 3, 3, 2};
SparseMatrix x2 = { {{0,0,1},{0,1,2},{0,2,3},{1,0,1},{1,1,2},{1,2,3},{2,0,1},{2,1,2},{2,2,3}}, 3, 3, 9};
SparseMatrix y2 = { {{0,0,1},{0,1,1},{0,2,1},{1,0,1},{1,1,1},{1,2,1},{2,0,1},{2,1,1},{2,2,1}}, 3, 3, 9};
SparseMatrix x3 = { {{0,0,7},{0,2,2},{1,2,3},{2,0,7}}, 3, 3, 4};
SparseMatrix y3 = { {{0,1,5},{0,2,8},{1,2,4},{2,0,4},{2,2,1}}, 3, 3, 5};
- Á¦Ãâ ÆÄÀÏ ³»¿ë
- ÇÁ·Î±×·¥ ¼Ò½º
- µ¿ÀÛ È¸éÀ» ĸÃçÇÑ ±×¸²
- °úÁ¦Áß ¹ß»ýÇÑ ¹®Á¦, ÇØ°á¹æ¹ý, ¹è¿î °Í, ´À³¤Á¡À» Æ÷ÇÔÇÒ °Í
- ÁÖÀÇ»çÇ×: for loop¸¦ »ç¿ëÇÏ¿© ±¸ÇöÇÒ °Í (ÀÏÀÏÀÌ ¹è¿º° °öÇϱ⸦ ÇÏ´Â °Í ±ÝÁö)
|