#include "stdio.h" int main() { int num=0;int a[100]; int i=0; int m=0;int yushu; char hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};printf("请输入一个十进制整数:"); scanf("%d",&num); while(num>0) { y
“用C语言写一个函数测试当前机器的大小端模式”是一个经典的笔试题,如下使用两种方式进行解答: 1. 用union来测试机器的大小端 #include <stdio.h> union test { int a; char b; }; int endian_test(void) { union test t1; t1.a = ; return t1.b; } int main(void) { int i = endian_test(); ) { printf("is little end
// 字符串替换空格:请实现一个函数,把字符串中的每一个空格替换成"%20". // 比如输入"we are happy.",则输出"we%20are%20happy." #include <stdio.h> #include <assert.h> char* replace(char* p) { char* ret = p; int num = 0; int oldlen = 0; int newlen = 0; cha