#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
程序要怎么改?