题目内容

//斐波那契数列――迭代与递推算法//请选择相应位置的正确内容##include "stdio.h"#define N 12int main(){int a[N+1],i;//定义的数组中包含N+1个元素,0号元素不存放有效数据[A请选择]a[2]=2;[B请选择][C请选择]printf("%d\n",a[N]);return 0;}

查看答案
更多问题

//二维数组使用示例――处理多个学生多门课组成的成绩表//输入多个学生多门课程的成绩,分别求出每个学生的总成绩并按总成绩降序排序后输出完整的成绩表。//请选择相应位置的正确内容#include "stdio.h"#include "stdlib.h"#define RENSHU 10 //人数#define KECHENG 4 //课程数int main(){int a[RENSHU+1][KECHENG+1];//比课程数多定义一列,用于存放总分//多定义一行,数据从1号行开始存放,以便跟日常习惯一致int i,j,k;//以下程序用于按人(即按行)输入成绩printf("按行输入成绩(%d人,%d门课程):\n",RENSHU,KECHENG);for(i=1;i<=RENSHU;i++){printf("第%2d人:",i);for(j=0;j

//字符大小写转换示例//输入一行字符,将其中的小写字母转换为大写字母。//请选择相应位置的正确内容#include "stdio.h"#include "string.h"int main(){char str[80];unsigned int i;printf("请输入一行文字:\n");gets(str);//读入字符串并存入各数组元素中去printf("\n转换前:");printf("%s",str);//注意这儿用的格式符为%s而不是%cprintf("\n转换后:");for(i=0;i='a'))//若为小写字母则进行转换printf("%c",[A请选择]);//转换为对应大写字母并输出elseprintf("%c",[B请选择]); //不是小写字母,原样输出printf("\n\n");return 0;}

//多个字符串操作示例//对乱序的城市名称(共137个城市名),请将其按字母表顺序排列生成一个有序表以方便查看。//请选择相应位置的正确内容#include "stdio.h"#include "string.h"#define N 137int main(){//多定义一行,有效数据从1号行开始存放,初始化时给0号行赋空串//列数取15,因城市名最长为7个汉字, 14个字符,加上结束标志'\0',共15个char str[N+1][15]={"","北京市","上海市","天津市","重庆市","香港特别行政区","澳门特别行政区","合肥市","毫州市","芜湖市","马鞍山市","池州市","黄山市","滁州市","安庆市","淮南市","淮北市","蚌埠市","巢湖市","宿州市","宣城市","六安市","阜阳市","铜陵市","明光市","天长市","宁国市","界首市","桐城市","福州市","厦门市","泉州市","漳州市","南平市","三明市","龙岩市","莆田市","宁德市","建瓯市","武夷山市","长乐市","福清市","晋江市","南安市","福安市","龙海市","邵武市","石狮市","福鼎市","建阳市","漳平市","永安市","兰州市","白银市","武威市","金昌市","平凉市","张掖市","嘉峪关市","酒泉市","庆阳市","定西市","陇南市","天水市","玉门市","临夏市","合作市","敦煌市","甘南州","南宁市","贺州市","玉林市","桂林市","柳州市","梧州市","北海市","钦州市","百色市","防城港市","贵港市","河池市","崇左市","来宾市","东兴市","桂平市","北流市","岑溪市","合山市","凭祥市","宜州市","贵阳市","安顺市","遵义市","六盘水市","兴义市","都匀市","凯里市","毕节市","清镇市","铜仁市","赤水市","仁怀市","福泉市","海口市","三亚市","万宁市","文昌市","儋州市","琼海市","东方市","五指山市","石家庄市","保定市","唐山市","邯郸市","邢台市","沧州市","衡水市","廊坊市","承德市","迁安市","鹿泉市","秦皇岛市","南宫市","任丘市","葉城市","辛集市","涿州市","定州市","晋州市","霸州市","黄骅市","遵化市","张家口市","沙河市","三河市","冀州市","武安市"};unsigned int i,j;for(j=1;j<=N-1;j++)for(i=j+1;i<=N;i++)if([A请选择])//j行与i行进行比较{//利用0号行实现j行与i行的交换strcpy(str[0],str[j]);//利用函数strcpy()实现字符串赋值[B请选择][C请选择]}printf("按字母顺序排列的结果如下:\n\n");for(i=1;i<=N;i++)//序号3位,右对齐,不足3位补前导0;城市名16位,左对齐printf("%03d:%-16s",i,[D请选择]);//%-16s表示占16位,左对齐printf("\n");return 0;}

【8-5】(1)程序改错。程序功能:输入一行英文文本,将每一个单词的第一个字母变成小写。修改程序中的错误以后运行程序,写出输出结果。#include #include //tolower函数,toupper函数的头文件/**********【1】FOUND**********/void fun(char p){int k=0;/**********【2】FOUND**********/do while(*p=='\0'){if(k==0&&*p!=' '){*p=tolower(*p);/**********【3】FOUND**********/k=0;}else if(*p!=' ')k=1;elsek=0;/**********【4】FOUND**********/*p++;}}int main(){void fun(char *p);char str[81];printf("please input a English text line:");gets(str);printf("The original text line is :");puts(str);fun(str);printf("The new text line is :");puts(str);return 0;}

答案查题题库