Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- int int_com(char *st1, char *st2, int *sc1, int *sc2);
- char char_com(char *st1, char *st2, int *sc1, int *sc2);
- void output(char (*store)[20], int (*score)[7]);
- int main(void)
- {
- char store[4][20] = {"관악점","강남점","명동점","대림점"};
- int score[4][7] ={
- {70,45,100,92,150,81,0},
- {88,92,77,30,52,55,0},
- {50,90,88,75,77,49,0},
- {120,92,80,150,130,105,0}};
- char sv_store[4][20];
- int sv_score[4][7],i,j;
- for(i=0;i<4;i++)
- {
- strcpy(sv_store[i],store[i]);
- for(j=0;j<7;j++)
- {
- sv_score[i][j] = score[i][j];
- }
- }
- for(i=0;i<4;i++)
- {
- int temp=0;
- for(j=0;j<6;j++)
- temp+=score[i][j];
- double temp2 = (double)temp/6;
- //score[i][6] = (int)floor(temp2+0.5); //아...쓰는 편한데... 리눅스에서는 일반적에서는 컴파일에러.
- int temp3 = temp/6;
- if((temp2-(double)temp3)>=0.5) temp3++;
- score[i][6] = temp3;
- }
- printf("실적별 출력...\n");
- int_com(store[0],store[1],score[0],score[1]);
- int_com(store[0],store[2],score[0],score[2]);
- int_com(store[0],store[3],score[3],score[3]);
- int_com(store[1],store[2],score[1],score[2]);
- int_com(store[1],store[3],score[1],score[3]);
- int_com(store[2],store[3],score[2],score[3]);
- output(store,score);
- printf("\n\n지점별 출력...\n");
- output(sv_store,sv_score);
- return 0;
- }
- int int_com(char *st1, char *st2, int *sc1, int *sc2)
- {
- if(sc1[6]<sc2[6])
- {
- char temp[20];
- strcpy(temp,st2);
- strcpy(st2,st1);
- strcpy(st1,temp);
- for(int i=0;i<7;i++)
- {
- int temp;
- temp = sc2[i];
- sc2[i] = sc1[i];
- sc1[i] = temp;
- }
- }
- }
- char char_com(char *st1, char *st2, int *sc1, int *sc2)
- {
- if(strcmp(st1,st2)>0)
- {
- char temp[20];
- strcpy(temp,st2);
- strcpy(st2,st1);
- strcpy(st1,temp);
- for(int i=0;i<7;i++)
- {
- int temp;
- temp = sc2[i];
- sc2[i] = sc1[i];
- sc1[i] = temp;
- }
- }
- }
- void output(char (*store)[20], int (*score)[7])
- {
- int i=0,j=0;
- for(i=0;i<4;i++)
- {
- printf("%s ",store[i]);
- for(j=0;j<7;j++)
- {
- printf("%3d ",score[i][j]);
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement