为什么运行正确但是oj平台不给过嘞!!??

weixin_41301438 2018-04-10 09:30:31
Description

输入文件中每行是一个整数,要求按位输出。

Input


Output


Sample Input


-13
0
12345
Sample Output


-13 have two numbers,are 3,1
0 has one number,is 0
12345 have five numbers,are 5,4,3,2,1
Source
--------------------------------------------------------------
#include<stdio.h>
#include<math.h>
int main()
{
int n,a,i;
int count;
int t,n1;
while(scanf("%d",&n)!=EOF)
{
if(n<0)
n1=abs(n);
else
n1=n;
t=n1;
if(n==0)
printf("0 has one number,is 0");
else{
count=0;
while(t)
{
t/=10;
count++;
}
printf("%d have %d numbers,are ",n,count);

for(i=0;i<count;i++)
{
a=n1%10;
n1=n1/10;
if(i<count-1)
printf("%d,",a);
if(i==count-1)
printf("%d\n",a);
}
}
} }
...全文
2782 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2018-04-12
  • 打赏
  • 举报
回复
边界条件 输入输出格式 ……
qq_31908171 2018-04-12
  • 打赏
  • 举报
回复
整数的范围没有规定,建议用数组存
自信男孩 2018-04-11
  • 打赏
  • 举报
回复
#include<stdio.h>
#include <stdlib.h>
#include<math.h>

const char *digits[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve"};

int main()
{
    int n, t, cnt;
    int i;
    int digit_list[12];

    while(scanf("%d",&n)!=EOF)
    {
        if(n < 0)
            t = abs(n);
        else
            t = n;

        if (n == 0) {
            printf("0 has %s number, is 0\n", digits[n+1]);
            continue;
        }

        cnt = 0;
        while (t) {
            digit_list[cnt++] = t % 10;
            t /= 10;
        }

        i = 0;
        printf("%d has %s %s ", n, digits[cnt], cnt > 1 ? "numbers, are":"number, is");
        while (i < cnt - 1) {
            printf("%d,", digit_list[i]);
            i++;
        }
        printf("%d\n", digit_list[i]);
        /*
        count = 0;
        while(t)
        {
            t/=10;
            count++;
        }
        printf("%d have %d numbers,are ",n,count);

        for(i=0;i<count;i++)
        {
            a=n1%10;
            n1=n1/10;
            if(i<count-1)
                printf("%d,",a);
            if(i==count-1)
                printf("%d\n",a);
        }
        */
    }

    return 0;
}
参考一下吧
weixin_41301438 2018-04-11
  • 打赏
  • 举报
回复
引用 2 楼 mxway 的回复:
输入测试用例如下: 99999999999999999999999999999999999999999999999999999999999999 0123456 看下你的结果还对不?
012345这个不是个整数吧·······还有这个巨大的999··怎么处理啊请问!··
weixin_41301438 2018-04-11
  • 打赏
  • 举报
回复
引用 1 楼 hdt 的回复:
是one不是1
那这个咋处理呢,总不能列举吧·····
mxway 2018-04-11
  • 打赏
  • 举报
回复
输入测试用例如下: 99999999999999999999999999999999999999999999999999999999999999 0123456 看下你的结果还对不?
真相重于对错 2018-04-10
  • 打赏
  • 举报
回复
是one不是1

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧