[컴퓨터 프로그레밍] 시험공부중
경영정보시스템/[06-겨울학기] C언어 View Comments
주인장 휴대폰으로 메시지가 즉시 전송됩니다.
광고가 아니고, 무료 메시징 서비스이니 안심하고 사용하세요.
// 3x3 행렬을 나타내는 두 개의 2차원 배열 s와 d를 인수로 받아서
// s의 전치 행렬을 d에 저장하는 다음 함수를 작성하고 이 함수의 동작을 확인하시오.
// 전치 행렬은 행렬의 행과 열을 교환한 행렬이다.
// void transpose(int s[3][3], int d[3][3])
#include <stdio.h>
void transpose(int s[3][3], int d[3][3]);
main(void){
int from[3][3] = {
1,2,3,
4,5,6,
7,8,9
};
int to[3][3];
int k, l;
transpose(from,to);
for(k=0; k<3; k++){
for(l=0; l<3; l++)
printf("%d ", to[k][l]);
printf("\n");
}
return 0;
}
void transpose(int s[3][3], int d[3][3]){
// 1 2 3 1 4 7
// 4 5 6 -> 2 5 8
// 7 8 9 3 6 9
int i,j;
for(i=0; i<3; i++){
for(j=0; j<3; j++)
d[j][i] = s[i][j];
}
}
<문자열 길이에 관한>
#include <stdio.h>
#include <string.h>
#define praise "My sakes, that's a grand name!"
int main(void)
{
char name[40];
printf("What's your name? \n");
scanf("%s", name);
printf("Hello, %s. %s\n", name, praise);
printf("Your name of %d letters occupies %d memory cells. \n", strlen(name), sizeof name);
printf("The phrase of PRAISE has %d letters ", strlen(praise));
printf("and occupies %d memory cells. \n", sizeof praise);
}
== run ==
What's your name?
Sungjo (Enter)
Hello, Sungjo. My sakes, that's a grand name!
Your name of 6 letters occupies 40 memory cells.
The phrase of PRAISE has 30 letters and occupies 31 memory cells.
Press any key to continue
'경영정보시스템 > [06-겨울학기]' 카테고리의 다른 글
| [컴퓨터 프로그레밍] 시험공부중 (0) | 2007/01/16 |
|---|---|
| [컴퓨터 프로그래밍] 12일차 (0) | 2007/01/12 |
| [컴퓨터 프로그래밍] 1월 9일 과제 제출 (0) | 2007/01/10 |
| [컴퓨터 프로그래밍] 10일차 (0) | 2007/01/10 |
| [컴퓨터 프로그래밍] 1월 9일 과제 (0) | 2007/01/09 |
| [컴퓨터 프로그래밍] 9일차 (0) | 2007/01/09 |
Twitter
Facebook
Flickr
RSS

back to top