C语言练习题库
城春无悲喜
这个作者很懒,什么都没留下…
展开
-
容易——字符数组——输入字符串,包含:字母、数字、标点符号,以及空格字符,并将其逆序输出。
输入字符串,包含:字母、数字、标点符号,以及空格字符,并将其逆序输出。例如,当输入字符串为“I am a student.”,输出为“.tneduts a ma I”,假设字符数组最大长度为30。输入提示信息:“Please Enter String1:\n”输入格式:gets()输出格式:“Result is:\n%s\n”程序运行结果示例:Please Enter String1:I am a student.↙Result is:.tneduts a ma I#include &原创 2021-06-08 22:56:41 · 1428 阅读 · 0 评论 -
容易——字符数组——字符串转换成整数
输入一个以回车结束的字符串(少于10个字符),它由数字字符组成,将该字符串转换成整数后输出。注意,不能直接调用库函数atoi完成。**输入提示信息:"Enter a string: "**输出格式要求:“digit = %d\n”程序运行示例如下:Enter a string: 123digit = 123#include<stdio.h>int main(){ int i=0, n=0; char a[10]; printf("Enter a stri原创 2021-06-08 22:52:49 · 666 阅读 · 0 评论 -
容易——字符数组——找出字符串中最大字符元素
编程实现找出字符串中最大字符元素并输出该元素及其对应的ASCII值.****要求输入提示信息为:“Input a string:\n”****输出格式要求为:“The largest character of “%s” is ‘%c’ ,The ASCII is %d.”程序运行示例:Input a string:↙I am a student.The largest character of “I am a student.” is ‘u’ ,The ASCII is 117.↙#inc原创 2021-06-07 21:15:19 · 3081 阅读 · 0 评论 -
容易——字符数组——改错——统计英文字符、数字字符、空格字符,以及其他字符的个数
输入一行字符,统计其中的英文字符、数字字符、空格字符,以及其他字符的个数。请找出以下程序的错误,并改正之。#include <stdio.h>#include <string.h>#define ARR_SIZE 80int main(){ char str[ARR_SIZE]; int len, i; int letter=0,digit=0,space=0,other=0; printf("请输入一个字符串:"); ge原创 2021-06-07 21:04:34 · 331 阅读 · 0 评论 -
容易——字符数组——回文判断
有趣的“回文”检测英文中有很多的回文词,回文词的拼法十分有趣,无论是从前往后拼读,还是从后往前拼读,他们的拼法和词义都不变。例如:dad(爸爸),mum(妈妈),noon(中午),eve(前夕),eye(眼睛),pop(流行),deed(行为),level(水平)等。简单地说,“回文”就是指顺读和倒读都一样的字符串。现在请你编程输入一个单词,判断它是否是回文。#include<stdio.h>#include<string.h>int main(){ char a原创 2021-06-07 21:00:54 · 672 阅读 · 0 评论 -
容易——字符数组——字符串逆序
输入一个字符串,将其逆序输出。输入提示信息:“Please Enter String1:\n”输入字符串用gets()输出提示信息和输出格式:“Result is:\n%s\n”程序运行示例:Please Enter String1:hello world!↙Result is:!dlrow olleh#include <stdio.h>#include <string.h>int main(void){ int len, i; char s原创 2021-06-07 20:54:08 · 171 阅读 · 0 评论 -
容易——字符数组——统计英文字符、数字字符、空格和其他字符的个数
输入一行字符,统计其中的英文字符、数字字符、空格和其他字符的个数。输入提示信息:“Please input a string:”输入字符串用gets()输出提示信息和格式:“English character: %d\n”“digit character: %d\n”“space: %d\n”“other character: %d\n”程序运行示例:Please input a string:dytxx246$6@,.English character: 5digit原创 2021-06-07 20:50:11 · 678 阅读 · 0 评论