#include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { int len ; int i ; int flag = 0 ; int count = 0 ; char buffer[20] = {'\0'} ; gets(buffer); puts(buffer); for(i = 0 ; i < strlen(buffer) ; i++) { //判断输入字符串中间有没有
//编写一个函数:tt指向一个M行N列的二维数组,求出二维数组每列中最小的元素,并依次放入pp所指的一维数组中.二维数组中的数在主函数中赋予. //重难点:求出的是每一列的最小值,这里要注意,学会简化代码,省去一些多余定义的变量. #include <stdio.h> #define M 3 #define N 4 void fun ( int tt[M][N], int pp[N] ) { //简化代码 int i, j;//不定义变量n,使用i即可.不定义min直接赋值给pp即可. ; i
SPOJ Problem Set (classical) 694. Distinct Substrings Problem code: DISUBSTR Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20; Each test case consists of one string, whose length is <=
import java.util.Scanner; /** * [程序38] * * 题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度. * * @author James * */ public class 第三十八题统计字符串的长度 { public static void main(String[] args) { System.out.println("请输入一个字符串"); Scanner in = new Scanner(System.in);
*6.20(计算一个字符串中字母的个数)编写一个方法,使用下面的方法头计算字符串中的字母个数: public static int countLetters(String s) 编写一个测试程序,提示用户输入字符串,然后显示字符串中的字母个数. *6.20(Count the letters in a string) Write a method that counts the number of letters in a string using the following header: p