标题:柱状图~
取消只看楼主
black0fish
Rank: 1
等 级:新手上路
帖 子:51
专家分:0
注 册:2006-9-5
 问题点数:0 回复次数:0 
柱状图~

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

main()
{
int *p,n=0,i,j;
char t;
char q[11][20]={"0:","10:","20:","30:","40:","50:","60:","70:","80:","90:","100:"};
p=(int*)malloc(100*sizeof(int));
while(*(p-1)!=-1)
{
scanf("%ld",p);
p++;
n++;
}
p=p-n;
for(i=0;i<n-1;i++)
{
switch (*(p++)/10)
{
case 0:
strcat(q[0],"*");
break;

case 1:
strcat(q[1],"*");
break;
case 2:
strcat(q[2],"*");
break;
case 3:
strcat(q[3],"*");
break;
case 4:
strcat(q[4],"*");
break;
case 5:
strcat(q[5],"*");
break;
case 6:
strcat(q[6],"*");
break;
case 7:
strcat(q[7],"*");
break;
case 8:
strcat(q[8],"*");
break;
case 9:
strcat(q[9],"*");
break;
case 10:
strcat(q[10],"*");
break;
}
}
for(i=0;i<=10;i++)
{
printf("%s\n",q[i]);
}
free(p);
}

输入一串整数(0-100),假设输入10,20,20,30然后输出格式如下:
0;
10;*
20;**
30;*
40;
50;
60;
70;
80;
90;
100;

上面那个程序是对的!现在我要把程序的输入格式变成垂直的:
*
* * *
0 10 20 30 40 50 60 70 80 90 100

程序要怎么改?

搜索更多相关主题的帖子: 柱状 include char int 
2006-10-17 10:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-96860-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.082002 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved