【发布时间】:2023-04-06 21:35:01
【问题描述】:
我想编写一个程序,使用scanf() 从标准输入中读取数字列表(每行一个)并打印横向图表。
例如,我使用我创建的数据文件:
./p6
5:#####
40:####################################### 51:############################################### ###
...
26:########################## 46:#############################################
14:##############
这是我第一次尝试的代码:
int main ()
{
int i; //i is integer and s is symbol
char s = '#'; //s is a character with symbol should be converted
printf ("Enter an integer\n");
scanf ("%d", &i);
i = s; // i is an interger from input should be converted to s
printf ("%d: %d\n", i, s);
return 0;
}
输出:
Enter an integer
35: 35
我不明白为什么或如何?
请帮帮我。
【问题讨论】:
-
你有什么不明白的?
-
您需要一个循环来在图表中重复该字母。