【发布时间】:2014-08-14 15:02:13
【问题描述】:
我需要一种方法来打印带有前导零的long,格式为123,456,逗号在第 3rd 和第 4th 位之间。我现在有这个代码:
#include <stdio.h>
void printWithComma (long num);
int main (void)
{
long number;
printf ("\nEnter a number with up to 6 digits: ");
scanf ("%ld", &number);
printWithComma (number);
return 0;
}
void printWithComma (long num)
{
//method to print the 6 digit number separated by comma
}
示例输出
运行 1
Enter a number with up to 6 digits: 123456
The number you entered is 123,456
运行 2
Enter a number with up to 6 digits: 12
The number you entered is 000,012
【问题讨论】:
-
首先,花一些时间来格式化你的问题(如果有,因为我没有看到)
-
向我们展示你的尝试,不要只是复制粘贴你的作业!
-
...你的问题是...?
-
嘘!您再次删除了所有代码格式!此外,this 已被多次询问 SO 本身!
-
printf("%06d", number);
标签: c