printf转换的问题很长很长 [英] Trouble with printf conversion long long

查看:92
本文介绍了printf转换的问题很长很长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究项目欧拉问题,就其本质而言,这种问题迫使您使用具有大容量存储空间的数据类型.

I've been working on a project euler problem, which by their very nature coerce you to use data types with big storage.

#include <stdio.h>
#include <conio.h>
#define num 600851475143

int main()
{
long long i, j, count=0, number=num, k;
for(i=2;number!=1;i++)
{
    count=0;
    for(j=1;j<=i;j++)
    {
        if((i%j)==0)
        {
            count++;
        }
    }
    for(k=0;k<100000000;k++)
    {}
    if(count==2)
    {
        printf("                      %d\n", i);
        if(number%i==0)
        {
            number/=i;
            printf("      %d\n", number);
            printf("%d\n", i);
            i=2;
        }
    }
}
getch();
return 0;
}

当我编译并运行程序时,没有打印任何数字.我尝试了%f,%l的各种printf转换,我更改了数据类型.我正在使用GNU GCC编译器.我该怎么办?

When I compile and run the program, there is nothing printed for number. I have tried various printf conversions %ll, %l, I have changed data types. I am using GNU GCC compiler. What should I do?

推荐答案

您应该(重新)阅读文件,我想是

You should (re)read the documentation, I guess.

%ll无效,因为ll不是一个完整的说明符,它只是实际转换说明符的修饰符,应该紧随其后.

%ll didn't work since ll is not a complete specifier, it's just a modifier for the actual conversion specifier, which should follow.

尝试%lld.

这篇关于printf转换的问题很长很长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆