프로그래밍 c언어 시험 (01장~10장)
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
해당 자료는 10페이지 까지만 미리보기를 제공합니다.
10페이지 이후부터 다운로드 후 확인할 수 있습니다.

본문내용

");
}
/* 다음과 같은 행렬의 곱을 수행하는 프로그램을 작성하시오.*/
#include
#define rows 2
#define cols 3
typedef double matrixa[rows][cols];
typedef double matrixb[cols][rows];
typedef double resultc[rows][rows];
void multiply(resultc r, matrixa a, matrixb b);
void display(resultc r, int m);
int main(void)
{
matrixa a = {{4.2, 4.3, 3.8}, {3.7, 1.5, 0.7}};
matrixb b = {{5.2, 2.1}, {3.2, 1.4}, {1.5, 3.6}};
resultc r = {0};
int i, j;
for(i=0 ; i < rows; i++)
{
for(j=0 ; j < cols; j++)
{
printf("%8.2f", a[i][j]);
}
printf("\n");
}
printf("\n");
display(b, cols);
printf("다음은 위 두 행렬의 곱 결과입니다.\n\n");
multiply(r, a, b);
display(r, rows);
return 0;
}
void multiply(resultc r, matrixa a, matrixb b)
{
int i, j, k;
for(i=0; i < rows ; i++)
{
for(j=0; j < rows ; j++)
{
for(k=0; k < cols; k++)
{
//r[i][j] += a[i][k] * b[k][j];
*(r[i] + j) += *(a[i] + k)* *(b[k] + j);
}
}
}
}
void display(resultc r , int m)
{
int i, j;
for(i=0; i {
for(j=0; j {
printf("%8.2f", r[i][j]);
}
printf("\n");
}
printf("\n");
}
/* 배열 포인터를 이용하여 다음의 이차원 배열에서 모든 원소의 값을 5씩
증가시키는 프로그램을 작성하시오.*/
#include
void plus(int (*array)[2][5], int n);
int main(void)
{
int i, len;
int ary[][5] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
len = sizeof(ary)/sizeof(int);
printf(" << 변경 전 >>\n");
for(i = 0 ; i < len ; i++)
{
printf("%d ", ary[0][i]);
}
printf("\n\n");
plus(&ary, len);
printf(" << 변경 후 >>\n");
for(i = 0 ; i < len ; i++)
{
printf("%d ", ary[0][i]);
}
printf("\n");
return 0;
}
void plus(int (*array)[2][5], int n)
{
int i;
for(i = 0 ; i < n ; i++)
{
(*array)[0][i] += 5;
}
}
/* 자료 유형 double 형 1차원 배열을 다음과 같이 초기화하고, 첫 번째 인자인 배열
source를 두 번째인 인자인 배열target에 복사하는 함수를 만들어 결과를 알아보는
프로그램을 작성하시오.*/
#include
#include
void copyarray(double *source,double *target,int size);
int main(void)
{
double ary[5] = {3.12, 5.14, 7.25,7.48, 5.91 };
double *target;
int i;
target = (double *)malloc(sizeof(double) * 5);
copyarray(ary,target,5);
printf("source array : ");
for(i=0;i<5;i++)
{
printf("%3.2lf ",ary[i]);
}
printf("\n\ntarget array : ");
for(i=0;i<5;i++)
{
printf("%3.2lf ",target[i]);
}
printf("\n");
return 0;
}
void copyarray(double *source,double *target, int size)
{
int i;
for(i=0;i {
target[i] = source[i];
}
}
/* 자료 유형 double 형 1차원 배열에서 가장 큰 값과 가장 작은 값을 찾아 그값의 차이를
반환하는 함수를 만들어 결과를 알아보는 프로그램을 작성하시오.*/
#include
#include
double cal(double *source,int size);
int main(void)
{
double ary[5] = {3.12, 5.14, 7.25,7.48, 5.91 };
printf("The max - the min = %3.2lf \n",cal(ary, 5));
return 0;
}
double cal(double *source,int size)
{
double max = source[0];
double min = source[0];
int i;
for(i=1;i {
if(max < source[i]) max = source[i];
if(min > source[i]) min = source[i];
}
return (max - min);
}
/* 다음과 같이 int형 변수에 i에 0x324F3A24를 정의하여 char*변수 pc를 선언하여pc
변수를 이용하여 i의 저장값을 16진수를 324F3A24로 출력하는 프로그램을 작성하시오.*/
#include
int main(void)
{
int i = 0x324F3A24;
char *cp=(char*)&i;
printf("%X%X%X%X\n",cp[3],cp[2],cp[1],cp[0]);
return 0;
}
  • 가격4,000
  • 페이지수76페이지
  • 등록일2012.08.23
  • 저작시기2012.8
  • 파일형식한글(hwp)
  • 자료번호#761909
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니