3*45행렬을 37*37 행렬로 바꾸는데요![인접행렬]
비예
질문 제목 : 질문 내용 : #include stdio.h
#include stdlib.h
#define stack_len 37
#define list_len 100
#define true 1;
#define false 0;
typedef int data;
typedef struct _arraystack
{
data stackarr[stack_len];
int topindex;
} arraystack;
typedef arraystack stack;
void stackinit(stack *pstack)
{
pstack-topindex=-1;
}
int sisempty(stack *pstack)
{
if(pstack-topindex==-1){
return true;
}
else
return false;
}
void spush(stack *pstack, data data)
{
pstack-topindex+=1;
pstack-stackarr[pstack-topindex]=data;
}
data spop(stack *pstack)
{
int ridx;
if(sisempty(pstack))
{
printf(stack memory error!);
exit(-1);
}
ridx=pstack-topindex;
pstack-topindex-=1;
return pstack-stackarr[ridx];
}
typedef int ldata;
typedef struct _node
{
ldata data;
struct _node *next;
}node;
typedef struct _arraylist
{
ldata arr[list_len];
int numofdata;
int curposition;
int score;
}arraylist;
typedef arraylist list;
//void listinit(list *plist)
//{
//plist-head=(node*)malloc(sizeof(node));
//plist-head-next=null;
//plist-comp=null;
//plist-numofdata=0;
//}
void linsert(list *plist, ldata data)
{
if(plist-numofdatalist_len) //용량초과
{puts(저장이 불가능);
return;
}
plist-arr[plist-numofdata]=data;
(plist-numofdata)++;
}
int lfirst(list *plist, ldata *pdata)
{
if(plist-numofdata==0)
return false;
(plist-curposition)=0;
*pdata=plist-arr[0];
return true;
}
int lnext(list *plist, ldata *pdata)
{
if(plist-curposition=(plist-numofdata)-1)
return false;
(plist-curposition)++;
*pdata=plist-arr[plist-curposition];
return true;
}
int main()
{
file *fp;
int i, j, k;
int temp1=0;
int temp2=0;
int temp3=0;
int stack1[3][45];
int stack2[37][37];
list list;
int data;
fp=fopen(member.txt, r);
for(i=0;i3;i++){
for(j=0;j45;j++)
{
fscanf(fp, %d,&stack1[i][j]); //stack1으로 txt파일을 행렬도 바꿈
}
}
//1단계
for(i=0;i37;i++){
for(j=0;j37;j++){
stack2[i][j]=0;
}
}
//for(i=0;i34;i++){
for(k=0;k45;k++){
temp1=stack1[1][k];
temp2=stack1[2][k];
temp3=stack1[3][k];
stack2[temp1][temp2]=temp3;
//여기서 행렬안에 변수라서그런지 안들어가네요 ㅠㅠ-8599640 이런 값만 나오구요 ㅠㅠ
행렬저렇게 대입하고 싶은데, 어떻게 하면좋을까요
}
printf(%d\n, temp3);
}//2단계 인접행렬 만들기
return 0;
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2695766 | 달팽이 배열 어디서 틀렸는지 모르겠습니다ㅠㅠ | 연분홍 | 2025-05-23 |
2695738 | fopen과fclose질문~~ (5) | 희선 | 2025-05-23 |
2695707 | 3의 배수 나타내기. (2) | 수리 | 2025-05-23 |
2695626 | 피보나치수열 과제 때문에 질문 드립니다. (6) | 옆집언니 | 2025-05-22 |
2695595 | 포인트공부중입니다 int형에서 4=1 인가요? (3) | 족장 | 2025-05-22 |
2695567 | 드라이브 고유번호를 가져오는 함수 (2) | 초코맛사탕 | 2025-05-21 |
2695533 | 음수의 산술변환! 질문이요 ㅠㅠ... (4) | 꽃여름 | 2025-05-21 |
2695506 | 구조체 배열 이용 도서목록 출력 프로그램 (1) | 가을귀 | 2025-05-21 |
2695450 | c언어 함수 질문이요.... | 이슬비 | 2025-05-20 |
2695403 | VirtualAlloc함수 및 메모리 질문 | 크리에이터 | 2025-05-20 |
2695355 | c언어 for함수 | 미쿡 | 2025-05-19 |
2695327 | 안녕하세요 제가 이번에 좀 큰 프로그램을.. | 악당 | 2025-05-19 |
2695295 | mutex동기화의 thread기반 채팅 서버소스 질문입니다 | 그루터기 | 2025-05-19 |
2695270 | 질문이요..swap 관한겁니다..ㅠㅠ (3) | 콩알녀 | 2025-05-19 |
2695244 | 노땅초보궁금한게 하나 있는데요..반복문(while문)초보자질문 (6) | 큰꽃늘 | 2025-05-18 |
2695166 | do while 문 어떤것이잘못된건지 모르겠어요 (2) | 아이폰 | 2025-05-18 |
2695122 | 구조체에 대해 물어보고 싶은게 있습니다 ^^^.. (7) | 수련 | 2025-05-17 |
2695091 | txt 파일 입출력 후 2차 배열에 저장하기입니다. (3) | 헛장사 | 2025-05-17 |
2695063 | 수도요금 프로그램좀 짜주세요. | 시내 | 2025-05-17 |
2695033 | 답변좀요ㅠㅠ (1) | 비사벌 | 2025-05-16 |