随笔分类 - c/c++
摘要:1、 #include <stdio.h> int main(void) { char ch; ch = getchar(); while(ch != '\n') { if(ch == ' ') { putchar(ch); } else { putchar(ch + 1); } ch = getc
        阅读全文
                
摘要:1、 #include <stdio.h> #define NUM 26 int main(void) { char letters[NUM]; int i; for(i = 0; i < NUM; i++) { letters[i] = 'a' + i; } for(i = 0; i < NUM;
        阅读全文
                
摘要:1、 #include <stdio.h> int main(void) { char ch; scanf("%c", &ch); while(ch != 'g') { printf("%c", ch); scanf("%c", &ch); } return 0; }
        阅读全文
                
摘要:c语言中复合赋值运算符的等级低于普通赋值运算符。 #include <stdio.h> int main(void) { int num1 = 2; int num2 = 2; num1 *= 3 + 8; // 等价于 num1 = num1 * (3 + 8);说明复合赋值运算符的优先级等于算术
        阅读全文
                
摘要:1、 #include <stdio.h> #define M_PER_HOUR 60 int main(void) { int min; int hour, min_left; printf("please input the minutes to convert: "); scanf("%d",
        阅读全文
                
摘要:c语言中指数增长程序。 #include <stdio.h> #define SQUARES 64 int main(void) { const double CROP = 2E16; double current, total; int count = 1; printf("square grai
        阅读全文
                
摘要:c语言中的指数运算。 #include <stdio.h> #include <math.h> int main(void) { float tmp; tmp = pow(2,3); printf("pwo(2,3) = %f.\n", tmp); return 0; }
        阅读全文
                
摘要:1、编写一个程序,提示用户输入名和姓, 然后以“名,姓”的格式打印出来。 #include <stdio.h> int main(void) { char name[128]; char surname[128]; printf("please input your name: "); scanf(
        阅读全文
                
摘要:\0oo: 用八进制数表示字符,o必须为有效的八进制数(0-7), 也可以写成 \oo的形式。 1、 #include <stdio.h> int main(void) { printf("test1: %c.\n", '\041'); // 八进制数的41表示十进制数33 printf("test
        阅读全文
                
摘要:c语言中printf()函数也有一个返回值,它返回打印字符的个数。 #include <stdio.h> int main(void) { int num = 10; int count; count = printf("num:%d\n", num); //printf()函数的返回值是打印字符的
        阅读全文
                
摘要:1、 #include <stdio.h> #define TEST 58 //符号常量or对象式宏 int main(void) { printf("|%d|\n", TEST); printf("|%5d|\n", TEST); //5表示宽度 printf("|%-5d|\n", TEST);
        阅读全文
                
摘要:1、c语言中如何创建、存储、输出字符串、输出字符串的大小、字符串的长度 #include <stdio.h> #include <string.h> int main(void) { char name[128]; //使用数组存储字符串 int size, len; printf("please 
        阅读全文
                
摘要:#include <stdio.h> int main(void) { int ch; printf("please input an number for char type: "); scanf("%d", &ch); printf("%d is equivalent to %c.\n", ch
        阅读全文
                
摘要:1、 #include <stdio.h> #include <float.h> #include <limits.h> int main(void) { int big_int = 2147483647; float big_float = 3.4E38; float small_float = 
        阅读全文
                
摘要:1、c语言中如何处理整数值的上溢。 #include <stdio.h> int main(void) { int i; int j = 1; for(i = 1; i <= sizeof(int) * 8 - 1; i++) { j *= 2; } printf("j = %d.\n", j - 
        阅读全文
                
摘要:由于c语言中数据类型实际所占存储位数和精度和具体平台相关,c语言的规范并没有强制和详细的规定, 因此c语言程序在移植过程中可能会出现不同平台数据类型不兼容 的状况。 为了解决这个问题,c语言在可移植类型stdint.h和inttype.h中规定了精确宽度整数类型,以确保c语言的类型在各系统内功能相同
        阅读全文
                
摘要:c语言中使用sizeof()输出各种数据类型的大小。 #include <stdio.h> int main(void) { printf("short: %zd.\n", sizeof(short)); printf("int: %zd.\n", sizeof(int)); printf("lon
        阅读全文
                
摘要:c语言中浮点数的声明与输出。 [root@centos79 test]# cat test2.c #include <stdio.h> int main(void) { float f = 1000.0; double d = 1000.0; long double ld = 1000.0; pri
        阅读全文
                
摘要:char类型用于存储字符(比如字母或者标点),但是从技术层面讲,char类型是整数,因为char类型存储的是整数而不是字符。 计算机使用字符编码来处理字符,即 用特定的整数来表示特定的字符。 例如在ASCII编码中, 大写字母A存储的是65. char类型通常被定义为8位的存储单元。 通常1个字节被
        阅读全文
                
摘要:1、 #include <stdio.h> int main(void) { signed short ss= 100; unsigned short us= 100; signed int si= 100; unsigned int ui= 100; signed long sl= 100; un
        阅读全文
                
 
                    
                
 浙公网安备 33010602011771号
浙公网安备 33010602011771号