📄 graph.cpp
字号:
/*|\
|
|
|
|
| _
| _ |_| _
| |_| |_| |_|
| |_| |_| |_|
| _ |_| |_| |_|
| |_| |_| |_| |_| _
| |_| |_| |_| |_| |_|
| |_| |_| |_| |_| |_|
| |_| |_| |_| |_| |_|
+----------------------------------------------------------->
60以下 60-69 70-79 80-89 90-100
*/
#include <strstrea.h>
#include <iomanip.h>
#include "KeyScan.h"
#include "clsScoreSheet.h"
#include "funcdeclear.h"
#include <string.h>
#define __max(a,b) (((a)>(b))?(a):(b))
void showgraph(int x)
{
char scr[18][70]={0};
int i,j;
for (i=0; i<=16; i++) for (j=0; j<69; j++) scr[i][j]=32;
for (i=0; i<=14; i++) scr[i][3]='|';
for (i=4; i<=62; i++) scr[15][i]='-';
scr[0][2]='/'; scr[0][4]='\\';
scr[15][63]='>'; scr[15][3]='+';
strcpy(scr[16]," 60以下 60-69 70-79 80-89 90-100");
int cnt[5]={0}, cnt2[5] , score, maxcnt=0;
for (i=0; i<s.GetStudentCount(); i++)
{
score=s.GetScoreInt(i,x,0,1);
if (score>=9000) cnt[4]++;
else if (score>=8000) cnt[3]++;
else if (score>=7000) cnt[2]++;
else if (score>=6000) cnt[1]++;
else if (score>=0) cnt[0]++;
else ;
}
for (i=0; i<5; i++) maxcnt=__max(maxcnt,cnt[i]);
for (i=0; i<5; i++) cnt2[i]=(int)((double)(cnt[i]*14)/maxcnt+0.5);
for (i=0; i<5; i++)
{
for (j=14; j>=14-cnt2[i]+1; j--)
{
scr[j][10*i+12]='|';
scr[j][10*i+13]='_';
scr[j][10*i+14]='|';
}
scr[j][10*i+13]='_';
}
ostrstream oss(scr[17],70);
for (i=0; i<5; i++) oss<<setw(i==0?14:8)<<cnt[i]<<"人";
int ch;
while (1)
{
showheader();
for (i=0; i<=17; i++) cout<<" "<<scr[i]<<'\n';
cout<<"\n 我想...\n"
<<" 保存这张图表... Ctrl+S\n"
<<" 返回 Esc\n"
<<flush;
ch=scankey(0,0,'s'-96,KEY_ESC,0);
if (ch==KEY_ESC) return;
savegraph(scr);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -