C Primer Plus_第9章_函数_编程练习】的更多相关文章

1.题略 #include int main(void) { int i; char ch[26]; for (i = 97; i <= (97+25); i++) { ch[i-97] = i; printf("ch[%d] = %c\n", i-97, ch[i-97]); } printf("That is all! thanks~\n"); return 0; } 这是之前写的,有点乱,改了些如下: #include int main(void) {…
Practice 1. 输入分钟输出对应的小时和分钟. #include #define MIN_PER_H 60 int main(void) { int mins, hours, minutes; printf("Convert mins to hours and minutes\n"); printf("Please enter the mins: \n"); scanf("%d", &mins); while (mins >…
Practice 1.输入名字和姓氏,以"名字,姓氏"的格式输出打印. #include int main(void) { char name[20]; char family[20]; printf("My Handsome Master, please enter your name: \n"); scanf("%s %s", &name, &family); //名字和姓氏一起读的话,需要先输入名字再输入姓氏,中间要有空白字…
本文为博主辛苦总结,希望自己以后返回来看的时候理解更深刻,也希望可以起到帮助初学者的作用. 转载请注明 出自 : luogg的博客园 谢谢配合! day03_条件查询_排序_函数 清空回收站: PURGE recyclebin; 给表名,字段加别名 : 表名 + 别名 ; 字段 [as] 别名 ; 去重复 : select distinct first_name from employees; 删除重复数据 : 方法1,先查找不重复的,再复制一份查询后不重复的 方法2,用rowID方法 条件查询…
1.题略 /*返回较小值,设计驱动程序测试该函数*/ #include <stdio.h> double min (double a, double b); int main (void) { double x, y; printf ("Please enter two numbers: \n"); scanf ("%lf %lf", &x, &y); printf ("The smaller one is %lf\n"…
1. /*rain.c 针对若干年的降水量数据,计算年降水总量.年降水平均量,以及月降水平均量*/ #include <stdio.h> #define MONTHS 12 #define YEARS 5 int main (void) { //把数组初始化为2000到2004年的降水量数据 const float rain[YEARS][MONTHS] = //const声明和初始化数组可保护数据 { {4.3, 4.3, 4.3, 3.0, 2.0, 1.2, 0.2, 0.2, 0.4,…
1.题略 #include <stdio.h> int main(void) { ; printf("Please enter text here(end with Ctrl + Z):\n"); while (ch=getchar() != EOF) i++; printf("There are %d characters in text.\n", i); ; } 运行结果 输入第一个Ctrl+Z时,并没有结束,下一行再输入Ctrl+Z才检测到EOF.…
Review long代替int类型变量的原因是什么? 在您的系统中,long可以容纳比int更大的数:如果您确实需要处理更大的值,那么使用一种在所有系统上都保证至少是32位的类型会使程序的可移植性更好.(PS:用sizeof(int)查看我电脑中的int发现是4字符即32位,和long一样,但是long是标准的32位,int在我这64位的系统中定义的是32位,在其他系统可能是16位.无论如何,有个标准,最好按标准来设定,这样移植起来就方便) 要获得一个32位的有符号整数,可以使用哪些可以值得数…
1.编写通常接受一个参数(字符串的地址),并打印该字符串的函数.不过,如果提供了第二个参数(int类型),且该参数不为0,则该函数打印字符串的次数将为该函数被调用的次数(注意,字符串的打印次数不等于第二个参数的值,而等于函数被调用的次数).是的,这是一个非常可笑的函数,但它让读者能够使用本章介绍的一些技术.在一个简单的程序中使用该函数,以演示该函数是如何工作的. #include <iostream> using namespace std; );//默认b为0 void show(const…
程序清单8.1(inline内联函数) #include<iostream> using namespace std; inline double square(double x) {//inline表示内联函数 return x*x; } void main() { double a, b, c = 13.0; a = square(5.0); b = square(4.5+7.5); cout << "a=" << a << &quo…