일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 하이퍼레저패브릭
- #다차원포인터
- #C++ 연산자함수오버로딩
- #JAVASCRIPT
- #성적관리프로그램
- relative path
- #자바상속#자바이즈어#is~a
- hyperledger transaction
- git flow
- mac terminal command
- html5 new tag
- #3차원배열
- #1차원배열
- html multimedia
- 토큰경제
- html plug-in
- html code
- html id
- #C++ has~a
- html object
- html video
- #android activity
- html charset
- html youtube
- docker example
- #2차원배열
- #CallByAddress
- #binary
- border-box
- #bubbleSort
- Today
- Total
A sentimental robot
Call by address 본문
#include<stdio.h>
#pragma warning(disable : 4996);
void input(int *clas, char *pname, int *pscore);
void oper(int *pscore, float *pavg);
void output(int *clas, char*pname, int *pscore, float *pavg);
void main() {
int clas[3] = {0,};
char name[3][3][10];
int score[3][3][4] = {0,};
float avg[3][3] = {0,};
input(clas, **name, **score); // 1차원 주소로 맞추기
oper(**score, *avg);
output(clas, **name, **score, *avg);
}
void input(int *clas, char *pname, int *pscore) {
int i, j, k;
for (k = 0 ; k<3 ; k++) {
printf("Class number:");
scanf("%d", clas + k);
for (i = 0; i<3 ; i++) {
printf("Name input : ");
scanf("%s",(pname + k * 30) + (i * 10));
for (j = 0 ; j<3 ; j++) {
printf("Score input :");
scanf("%d", ((pscore + k * 12) + (i * 4)) + j);
}
}
}
}
void oper(int *pscore, float *pavg) {
int i, j, k;
for (k = 0; k<3; k++) {
for (i = 0; i<3; i++) {
for (j = 0; j<3; j++) {
*(((pscore + k * 12) + i * 4) + 3) += *(((pscore + k * 12) + i * 4) + j);
}
*((pavg + k * 3) + i ) = *(((pscore + k * 12) + i * 4) + 3) / 3.f;
}
}
}
void output(int *clas, char*pname, int *pscore, float *pavg) {
int i, j, k;
for (k = 0; k<3; k++) {
printf("%d\n", *(clas + k));
for (i = 0; i<3; i++) {
printf("%s\t",( pname + k * 30 )+ i * 10);
for (j = 0; j<4; j++) {
printf("%d\t", *(((pscore + k * 12) + i * 4) + j));
}
printf("%f\n", *(pavg + k * 3) + i);
}
}
}