일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- #1차원배열
- html plug-in
- relative path
- #JAVASCRIPT
- docker example
- html5 new tag
- #CallByAddress
- hyperledger transaction
- mac terminal command
- #다차원포인터
- #bubbleSort
- #C++ 연산자함수오버로딩
- html video
- #자바상속#자바이즈어#is~a
- #2차원배열
- git flow
- #성적관리프로그램
- 토큰경제
- html code
- 하이퍼레저패브릭
- #3차원배열
- #binary
- border-box
- #C++ has~a
- #android activity
- html charset
- html youtube
- html id
- html object
- html multimedia
- Today
- Total
A sentimental robot
2차원배열 본문
#include<stdio.h>
#pragma warning(disable:4996)
void main()
{
char name[3][10];
int i, j = 0;
int score[3][4] = { 0, };
float avg[3];
for (i = 0; i < 3 ; i++)
{
printf("Name input:");
scanf("%s", &name[i]);
for (j = 0; j < 1 ; j++)
{
printf("korean/english/math score:");
scanf("%d%d%d", &score[i][0], &score[i][1], &score[i][2]);
}
score[i][3] = score[i][0] + score[i][1] + score[i][2];
avg[i] = score[i][3] / 3.f;
printf("Sum : %d\n", score[i][3]);
printf("Average : %f\n", avg[i]);
}
}
#include<stdio.h>
#pragma warning(disable : 4996)
void main() {
char name[3][10];
int score[3][4];
float avg[3];
int i;
for (i = 0; i < 3 ; i++) {
printf("name input :");
scanf("%s", &name[i]);
printf("kor :");
scanf("%d", &score[i][0]);
printf("eng :");
scanf("%d", &score[i][1]);
printf("mat :");
scanf("%d", &score[i][2]);
score[i][3] = score[i][0] + score[i][1] + score[i][2];
avg[i] = score[i][3] / 3.f;
}
for(i=0;i<3;i++)
printf("name:%s\tsum:%d\tavg:%f\n", name[i], score[i][3], avg[i]);
}
#include <stdio.h>
#pragma warning(disable:4996)
void main() {
char name[3][10];
int i, j = 0;
int score[3][4] = { 0, };
float avg[3];
for (i = 0; i < 3; i++)
{
printf("name input :");
scanf("%s", name[i]);
for (j = 0; j < 3; j++) {
printf("score input : ");
scanf("%d", &score[i][j]);
score[i][3] += score[i][j];
avg[i] = score[i][3] / 3.f;
}
}
//출력
for (i = 0; i < 3; i++) {
printf("%s\t", name[i]);
for (j = 0; j < 4; j++)
{
printf("%d\t", score[i][j]);
}
printf("%f\n", avg[i]);
}
}
'C ' 카테고리의 다른 글
Pointer (0) | 2017.12.29 |
---|---|
[ ]대신*를 사용한 1차원 배열 (0) | 2017.12.29 |
1차원배열 (0) | 2017.12.29 |
함수를 활용한 사칙연산 (0) | 2017.12.29 |
for문을 활용한 구구단 (0) | 2017.12.29 |