Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int menu(void);
- void print_graph(char name[20], int *ps, int size, int cnt, int num);
- struct graph{
- char name[20];
- int score;
- };
- struct graph table[]; //일단 무제한(?), Warning....
- int main(void)
- {
- menu();
- printf("프로그램을 종료합니다.\n");
- return 0;
- }
- int menu(void)
- {
- int cnt=0, temp_num;
- while(1){
- int sele;
- printf("점수그래프출력프로그램v1\n");
- printf("1)입력 2)출력 3)종료\n");
- scanf("%d", &sele);
- if (sele==1){
- printf("이름와 점수를 입력하세요. 구분은 뛰어쓰기입니다.\n");
- printf("예)최나나 950 //||//■■■■■■■■■■■■■■■■■■■■■■■■■■■■\n");
- printf("--------------------------------------------------\n");
- printf(">");scanf("%s%d",table[cnt].name, &table[cnt].score);
- cnt++;
- }
- else if(sele==2){
- for(int i= 0;i<cnt;i++)
- {
- char *user_name = table[i].name;
- int score_num = table[i].score;
- int graph_num = score_num / 5;
- print_graph(user_name,&score_num,graph_num,cnt,i);
- }
- }
- else if(sele==3) break;
- else if(sele==4) printf("%d|%s|%d\n",cnt-2,table[cnt-1].name, table[cnt-1].score); //입력확인용 선택
- else printf("잘못입력했습니다. 다시입력하세요.");
- }
- }
- void print_graph(char name[20], int *ps, int size, int cnt, int num)
- {
- int mm = *ps - (*ps/10*10);
- if (mm>=5){if(mm-5>2) mm=1; else mm=0;} else {if(mm>2) mm=1; else mm=0;}
- int size_p = size + mm;
- printf("%s|",name);
- if(*ps<10)printf("| %d|",*ps);
- else if(*ps<100)printf("| %d|",*ps);
- else printf("|%d|",*ps);
- for(int i=0;i<size_p;i++)
- {
- printf("*");
- //printf("■");
- }
- printf("|\n");
- }
Add Comment
Please, Sign In to add comment