小编kap*_*pil的帖子

计算机是否需要更多的时间来乘以,除,减,添加两个大数而不是更小的数

我们(人)花费更多的时间来乘法,加法,除法和减去两个大数而不是两个小数.

计算机是否需要花费更多时间来5 * 2表示51234 * 987654或者是否在相同的时间内完成操作?

两个大于处理器字长的数字(例如两个128位数)怎么办?

我看到了文章https://en.wikipedia.org/wiki/Multiplication_algorithm

algorithm multiplication division subtraction addition

5
推荐指数
2
解决办法
1559
查看次数

为什么结构在以下编程中显示的内存少于实际内存

我写了一个程序

include<stdio.h>
struct record
{
    int i;
    char ch[20];
};
int main()
{
    struct record a,*b;
    b=&a;
    printf("intial pointer is %p and final is %p",b++,b);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

a的大小应为20 + 4 = 24,但输出为

intial pointer is 0x7fffb0455e40 and final is 0x7fffb0455e58
Run Code Online (Sandbox Code Playgroud)

算术是18个字节.为什么输出是这样的?

c struct pointers sizeof

0
推荐指数
1
解决办法
47
查看次数

在程序中打印无效字符

我写了这个程序

#include<stdio.h>
struct student
{
    char name[22];
    char rollno[10];
    unsigned long long int phno;

};
int main()
{
    int i,j;
    char c[1];
    struct student cse[10],*p;
    p=cse;
    for(i=0;i<3;i++)
    {
            printf("enter student name\n");
            gets(cse[i].name);
            printf("enter student roll number \n");
            gets(cse[i].rollno);
            printf("enter student phone number \n");
            scanf("%llu",&cse[i].phno);
            gets(c); //to catch the '\n' left unprocessed by scanf
    }
    for(i=0;i<3;i++);
    printf("the following is the information about CSE B student\n");
    printf("%-6s%-24s%-14s%-14s \n","S.no","student Name","Roll no","phone no.");
    for(i=0;i<3;i++)
    {
            printf("%-6d%-24s%-20s%-14llu \n",i+1,(*p).name,(*p).rollno,(*p).phno);
            ++p;
    }
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出是

the …
Run Code Online (Sandbox Code Playgroud)

c struct

-1
推荐指数
1
解决办法
495
查看次数

使用逗号运算符的意外输出

我写了一个程序

#include<stdio.h>
int main()
{
      int x=3;
       if((x)==1,2,4,5,6)
               printf("number found in the list\n");
       else
               printf("Number not found \n");

      return 0;
}
Run Code Online (Sandbox Code Playgroud)

我期待输出为"未找到数字",但它是"在列表中找到的数字"为什么会这样

c if-statement

-1
推荐指数
1
解决办法
109
查看次数

为什么带有静态main()类型的程序显示错误?

#include<stdio.h>
static int main()
{
   printf("foo");
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

代码给出了错误

nfo): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index …

c c++

-5
推荐指数
1
解决办法
1507
查看次数