我们(人)花费更多的时间来乘法,加法,除法和减去两个大数而不是两个小数.
计算机是否需要花费更多时间来5 * 2表示51234 * 987654或者是否在相同的时间内完成操作?
两个大于处理器字长的数字(例如两个128位数)怎么办?
我看到了文章https://en.wikipedia.org/wiki/Multiplication_algorithm
我写了一个程序
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个字节.为什么输出是这样的?
我写了这个程序
#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) 我写了一个程序
#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)
我期待输出为"未找到数字",但它是"在列表中找到的数字"为什么会这样
#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 ×4
struct ×2
addition ×1
algorithm ×1
c++ ×1
division ×1
if-statement ×1
pointers ×1
sizeof ×1
subtraction ×1