C语言程序设计精髓 第10周——字符串:C语言世界中的大力水手 练兵区——编程题

1有趣的“回文”检测(4分)

题目内容:

英文中有很多的回文词,回文词的拼法十分有趣,无论是从前往后拼读,还是从后往前拼读,他们的拼法和词义都不变。例如:dad(爸爸),mum(妈妈),noon(中午),eve(前夕),eye(眼睛),pop(流行),deed(行为),level(水平)等。简单地说,“回文”就是指顺读和倒读都一样的字符串。现在请你编程输入一个单词,判断它是否是回文。

提示:

(1)设置两个指针pStart和pEnd,让pStart指向字符串首部,让pEnd指向字符串尾部。

(2)利用循环从字符串两边对指针所指字符进行比较,当对应的两字符相等且两指针未超越对方时,使指针pStart向前移动一个字符位置(加1),使指针pEnd向后移动一个字符位置(减1),一旦发现两字符不等或两指针已互相超越(不可能是回文),则立即停止循环。

(3)根据退出循环时两指针的位置,判断字符串是否为回文。
程序的两次运行结果如下:
第1次
Input string:ABCCBA↙
Yes!
第2次
Input string:student↙
No!
输入提示信息:“Input string:”
输入格式: 用gets()函数
输出格式:
输出信息,不是回文:“No!\n”
输出信息,是回文:“Yes!\n”
为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。

时间限制:500ms内存限制:32000kb
C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
int isPalindrome(char *str){
	char *pStart, *pEnd;
	int len = strlen(str);
	pStart=str, pEnd=str+len-1;
	while(pStart < pEnd){
		if(*pStart != *pEnd) return 0;
		++pStart, --pEnd;
	}
	return 1;
}
int main()
{	
	printf("Input string:");
	char str[10000];
	gets(str);
	if(isPalindrome(str)){
		printf("Yes!\n");
	} else {
		printf("No!\n");
	}
}

用例测试结果 运行时间 占用内存 提示 得分
用例1通过 2ms 256kb
2
用例2通过 2ms 256kb
2
提交答案本次得分/总分:4.00/4.00分

2学生成绩管理系统V1.0(4分)

题目内容:

某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用一维数组作函数参数编程实现如下学生成绩管理:

(1)录入每个学生的学号和考试成绩;

(2)计算课程的总分和平均分;

(3)按成绩由高到低排出名次表;

(4)按学号由小到大排出成绩表;

(5)按学号查询学生排名及其考试成绩;

(6)按优秀(90 ~ 100)、良好(80 ~ 89)、中等(70 ~ 79)、及格(60 ~ 69)、不及格(0~59)5个类别,统计每个类别的人数以及所占的百分比;

(7)输出每个学生的学号、考试成绩。

程序运行结果示例:

Input student number(n<30):

6↙

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

1↙

Input student’s ID, name and score:

11003001 87↙

11003005 98↙

11003003 75↙

11003002 48↙

11003004 65↙

11003006 100↙

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

2↙

sum=473,aver=78.83

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

3↙

Sort in descending order by score:

11003006 100

11003005 98

11003001 87

11003003 75

11003004 65

11003002 48

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

4↙

Sort in ascending order by number:

11003001 87

11003002 48

11003003 75

11003004 65

11003005 98

11003006 100

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

5↙

Input the number you want to search:

11003004

11003004 65

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

6↙

<60 1 16.67%

60-69 1 16.67%

70-79 1 16.67%

80-89 1 16.67%

90-99 1 16.67%

100 1 16.67%

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

7↙

11003001 87

11003002 48

11003003 75

11003004 65

11003005 98

11003006 100

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

8↙

Input error!

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

0↙

End of program!

输入格式:

( 1 )录入学生的人数:

             **输入数据格式:"%d"

             **提示信息:"Input student number(n<30):\n"

( 2 )录入每个学生的学号和考试成绩:

           **输入数据格式:"%ld%f"

           **提示信息:"Input student's ID, name and score:\n"

输出格式:

菜单项的输出显示:

Management for Students’ scores

1.Input record

2.Caculate total and average score of course

3.Sort in descending order by score

4.Sort in ascending order by number

5.Search by number

6.Statistic analysis

7.List record

0.Exit

Please Input your choice:

计算课程的总分和平均分:

          **输出总分与平均分格式:"sum=%.0f,aver=%.2f\n"

按成绩由高到低排出名次表:

          **输出格式:"%ld\t%.0f\n"

          **提示信息:"Sort in descending order by score:\n"

按学号由小到大排出成绩表:

          **输出格式:"%ld\t%.0f\n"

          **提示信息:"Sort in ascending order by number:\n"

按学号查询学生排名及其考试成绩:

           **如果未查到此学号的学生,提示信息:"Not found!\n"

           **如果查询到该学生,输出格式:"%ld\t%.0f\n"

按优秀(90 ~ 100)、良好(80 ~ 89)、中等(70 ~ 79)、及格(60~ 69)、不及格(0~59)5个类别,统计每个类别的人数以及所占的百分比:

            **成绩<60输出格式:"<60\t%d\t%.2f%%\n"

            **成绩=100输出格式:"%d\t%d\t%.2f%%\n"

            **其他输出百分比格式:"%d-%d\t%d\t%.2f%%\n" 

为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。

时间限制:500ms内存限制:32000kb
C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#define MAXN 1000
int n; //represent students number
typedef struct {
	long int stuID;
	char name[MAXN];
	float score;
}STUDENT;
STUDENT stu[MAXN];
//0 代表降序 1代表升序 
int cmpByScore1(const void *a, const void *b){
	STUDENT *s1 = (STUDENT *)a;
	STUDENT *s2 = (STUDENT *)b;
	return s1->score - s2->score;
}
int cmpByScore0(const void *a, const void *b){
	STUDENT *s1 = (STUDENT *)a;
	STUDENT *s2 = (STUDENT *)b;
	return s2->score - s1->score;
}
int cmpByNumber0(const void *a, const void *b){
	STUDENT *s1 = (STUDENT *)a;
	STUDENT *s2 = (STUDENT *)b;
	return s2->stuID - s1->stuID;
}
int cmpByNumber1(const void *a, const void *b){
	STUDENT *s1 = (STUDENT *)a;
	STUDENT *s2 = (STUDENT *)b;
	return s1->stuID - s2->stuID;
}
void menu(); 
void inputRecord();
void calc();
void sortByScore(int order);
void sortByNumber(int order);
void searchByNumber();
void analysis();
void print();
void Exit();
int main()
{	
	printf("Input student number(n<30):\n");
	scanf("%d", &n);
	while(1){
		menu();
	}
	
}
void menu(){
	printf("Management for Students' scores\n");
	printf("1.Input record\n");
	printf("2.Caculate total and average score of course\n");
	printf("3.Sort in descending order by score\n");
	printf("4.Sort in ascending order by number\n");
	printf("5.Search by number\n");
	printf("6.Statistic analysis\n");
	printf("7.List record\n");
	printf("0.Exit\n");
	printf("Please Input your choice:\n");
	int choice;
	scanf("%d", &choice);
	switch(choice){
		case 1: inputRecord(); break;
		case 2: calc(); break;
		case 3: sortByScore(0); break;
		case 4: sortByNumber(1); break; 
		case 5: searchByNumber(); break;
		case 6: analysis(); break;
		case 7: print(); break;
		case 0: Exit();
		default: printf("Input error!\n");
	}
}
void inputRecord(){
	printf("Input student's ID, name and score:\n");
	int i;
	for(i=0; i<n; ++i){
		scanf("%ld%f", &stu[i].stuID, &stu[i].score);
	}
}
void calc(){
	int i;
	float sum=0, avg;
	for(i=0; i<n; ++i){
		sum+=stu[i].score;
	}
	avg=sum/n;
	printf("sum=%.0f,aver=%.2f\n", sum, avg);
}
void sortByScore(int order){
	//0 代表降序 1代表升序 
	if(order){
		qsort(stu, n, sizeof(stu[0]),cmpByScore1);
	}  else {
		qsort(stu, n, sizeof(stu[0]),cmpByScore0);
	}
	printf("Sort in descending order by score:\n");
	int i;
	for(i=0; i<n; ++i){
		printf("%ld\t%.0f\n", stu[i].stuID, stu[i].score);
	}
}
void sortByNumber(int order){
	//0 代表降序 1代表升序 
	if(order){
		qsort(stu, n, sizeof(stu[0]),cmpByNumber1);
	}  else {
		qsort(stu, n, sizeof(stu[0]),cmpByNumber0);
	}
	printf("Sort in ascending order by number:\n");
	int i;
	for(i=0; i<n; ++i){
		printf("%ld\t%.0f\n", stu[i].stuID, stu[i].score);
	}
}
void searchByNumber(){
	printf("Input the number you want to search:\n");
	long int id;
	scanf("%ld", &id);
	int i;
	for(i=0; i<n; ++i){
		if(stu[i].stuID==id){
			printf("%ld\t%.0f\n", stu[i].stuID, stu[i].score);
			return;
		}
	}
	printf("Not found!\n");
}
void analysis(){
	int i, cnt[6]={0};
	for(i=0; i<n; ++i){
		if(stu[i].score>=100) cnt[5]++;
		else if(stu[i].score>=90) cnt[0]++;
		else if(stu[i].score>=80) cnt[1]++;
		else if(stu[i].score>=70) cnt[2]++;
		else if(stu[i].score>=60) cnt[3]++;
		else cnt[4]++;
	}
	printf("<60\t%d\t%.2f%%\n", cnt[4], 100*(float)cnt[4]/n);
	
	printf("%d-%d\t%d\t%.2f%%\n", 60, 69, cnt[3], 100*(float)cnt[3]/n);
	printf("%d-%d\t%d\t%.2f%%\n", 70, 79, cnt[2], 100*(float)cnt[2]/n);
	printf("%d-%d\t%d\t%.2f%%\n", 80, 89, cnt[1], 100*(float)cnt[1]/n);
	printf("%d-%d\t%d\t%.2f%%\n", 90, 99, cnt[0], 100*(float)cnt[0]/n);
	printf("%d\t%d\t%.2f%%\n", 100, cnt[5], 100*(float)cnt[5]/n);
}
void print(){
	int i;
	for(i=0; i<n; ++i){
		printf("%ld\t%.0f\n", stu[i].stuID, stu[i].score);
	}
}
void Exit(){
	printf("End of program!\n");
	exit(0);
}

用例测试结果 运行时间 占用内存 提示 得分
用例1通过 1ms 256kb
2
用例2通过 1ms 128kb
2
提交答案本次得分/总分:4.00/4.00分

3程序改错——1(4分)

题目内容:

下面程序的功能是,从键盘输入两个字符串,分别存放在字符数组d和s中,通过调用子函数MyStrcat( )将这两个字符串连接起来,并将连接后的字符串存放在字符数组r中,同时输出连接后的字符串。已知每个字符数组的最大长度为80。下面给出的程序存在错误,找到错误的原因后,请修改正确。并按照给出的程序运行结果示例检查你的程序。

已知函数原型:char* MyStrcat(char *dest, char *source);//函数返回连接后的字符串的首地址

#include <stdio.h>
#include <string.h>
int main(void)
{
        char *first, *second, *result;
        printf("Input the first string:\n");
        gets(first);
        printf("Input the second string:\n");
        gets(second);
        result = MyStrcat(first, second);
        printf("The result is : %s\n", result);
        return 0;
}
char* MyStrcat(char *dest, char *source)
{
        int i = 0;
        while (*(dest+i)!='\0')   i++;
        for (; *(source+i)!='\0'; i++)
        {
            *(dest+i) = *(source+i);   
        }
        return dest;
}

程序运行结果示例1:

Input the first string:

fri↙

Input the second string:

end↙

The result is : friend

程序运行结果示例2:

Input the first string:

home↙

Input the second string:

work↙

The result is : homework

输入提示信息:“Input the first string:\n”

输入提示信息:“Input the second string:\n”

输入格式: 使用gets()函数

输出格式:“The result is : %s\n”

为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。

时间限制:500ms内存限制:32000kb
C

#include <stdio.h>
#include <string.h>
char* MyStrcat(char *dest, char *source);
int main(void)
{
        char first[2*100], second[100], *result;
        printf("Input the first string:\n");
        gets(first);
        printf("Input the second string:\n");
        gets(second);
        result = MyStrcat(first, second);
        printf("The result is : %s\n", result);
        return 0;
}
char* MyStrcat(char *dest, char *source)
{
        int i = 0,  j = 0;
        while (*(dest+i)!='\0')   i++;
        for (; *(source+j)!='\0'; j++)
        {
            *(dest+i+j) = *(source+j);   
        }
        return dest;
}

用例测试结果 运行时间 占用内存 提示 得分
用例1通过 1ms 256kb
2
用例2通过 1ms 136kb
2
提交答案本次得分/总分:4.00/4.00分

4程序改错——2(4分)

题目内容:

下面程序的功能是输出如示例所示形式的数据,目前程序中存在错误,找到错误的原因后,请修改正确,并按照给出的程序运行结果示例检查你的程序。

程序中用到的函数原型如下:

void YH(int a[][ARR_SIZE], int n);

void PrintYH(int a[][ARR_SIZE], int  n);

程序运行结果示例:

   1

   1   1

   1   2   1

   1   3   3   1
#include<stdio.h>
#define  ARR_SIZE  5
void  YH(int a[][ARR_SIZE], int  n);
void  PrintYH(int a[][ARR_SIZE], int  n);
int main(void)
{
        int  a[ARR_SIZE][ARR_SIZE];
        YH(a, ARR_SIZE);
        PrintYH(a, ARR_SIZE);
        return 0;
}
void YH(int a[][ARR_SIZE], int n)
{
        int  i, j ;
        for (i=1; i<=n; i++)
        {  
             a[i][1] = 1;
             a[i][i] = 1;
        }
        for (i=3; i<=n; i++)
        {
            for (j=2; j<=i-1; j++)
            {
                 a[i][j] = a[i-1][j-1] + a[i-1][j];
            }       
        }
}
void PrintYH(int a[][ARR_SIZE], int n)
{
        int i , j ;
        for (i=1; i<n; i++)
        {
            for (j=1; j<=i; j++)
            {
                printf("%4d", a[i][j]);
            }
             printf("\n");
        }

输入格式: 无

输出格式: “%4d”

为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。

时间限制:500ms内存限制:32000kb
C

#include<stdio.h>
#define  ARR_SIZE  5
void  YH(int a[][ARR_SIZE], int  n);
void  PrintYH(int a[][ARR_SIZE], int  n);
int main(void)
{
        int  a[ARR_SIZE][ARR_SIZE];
        YH(a, ARR_SIZE-1);
        PrintYH(a, ARR_SIZE-1);
        return 0;
}
void YH(int a[][ARR_SIZE], int n)
{
        int  i, j ;
        for (i=0; i<n; i++)
        {  
             a[i][0] = 1;
             a[i][i] = 1;
        }
        for (i=2; i<n; i++)
        {
            for (j=1; j<=i-1; j++)
            {
                 a[i][j] = a[i-1][j-1] + a[i-1][j];
            }       
        }
}
void PrintYH(int a[][ARR_SIZE], int n)
{
    int i , j ;
    for (i=0; i<n; i++)
    {
        for (j=0; j<=i; j++)
        {
            printf("%4d", a[i][j]);
        }
         printf("\n");
    }
}

用例测试结果 运行时间 占用内存 提示 得分
用例1通过 1ms 256kb
4
提交答案本次得分/总分:4.00/4.00分

5出售金鱼(4分)

题目内容:

买买提将养的一缸金鱼分五次出售:第一次卖出全部的一半加二分之一条;第二次卖出余下的三分之一加三分之一条;第三次卖出余下的四分之一加四分之一条;第四次卖出余下的五分之一加五分之一条;最后卖出剩下的11条。问原来鱼缸中共有几条鱼?

输入格式: 无

输出格式:“There are %d fishes at first.\n”

为避免出现格式错误,请直接拷贝粘贴题目中给的格式字符串和提示信息到你的程序中。

时间限制:500ms内存限制:32000kb
C

#include<stdio.h>

int main()
{
	float sum=11;
	int cnt=5;
	while(cnt!=1){
		//printf("%f\n" , sum);
		sum=cnt*(sum + 1.0/cnt)/(cnt-1);
		cnt--;
	} 
	printf("There are %d fishes at first.\n", (int)sum);
}

用例测试结果 运行时间 占用内存 提示 得分
用例1通过 2ms 256kb
4
提交答案本次得分/总分:4.00/4.00分

6找最值(4分)

题目内容:

从键盘任意输入10个整数,用指针变量作函数参数编程计算最大值和最小值,并返回它们所在数组中的位置。函数原型如下所示:

int FindMax(int num[], int n, int *pMaxPos);//函数返回最大值,pMaxPos返回最大值所在的下标

int FindMin(int num[], int n, int *pMinPos);//函数返回最小值,pMaxPos返回最小值所在的下标

程序运行结果示例:

Input 10 numbers:

-1 2 3 45 92 8 9 12 7 8↙

Max=92,Position=4,Min=-1,Position=0

输入提示信息:“Input 10 numbers:\n”

输入格式: “%d”

输出格式:“Max=%d,Position=%d,Min=%d,Position=%d\n”

注意:为避免出现格式错误,请直接拷贝粘贴上面给出的输入、输出提示信息和格式控制字符串!

时间限制:500ms内存限制:32000kb
C

#include<stdio.h>
int FindMax(int num[], int n, int *pMaxPos);//函数返回最大值,pMaxPos返回最大值所在的下标

int FindMin(int num[], int n, int *pMinPos);//函数返回最小值,pMaxPos返回最小值所在的下标
int main()
{
	printf("Input 10 numbers:\n");
	int i, a[10], MaxPos, MinPos, Max, Min;
	for(i=0; i<10; ++i){
		scanf("%d", &a[i]);
	}
	Max=FindMax(a, 10, &MaxPos);
	Min=FindMin(a, 10, &MinPos);
	printf("Max=%d,Position=%d,Min=%d,Position=%d\n", Max, MaxPos, Min, MinPos);
}
int FindMin(int num[], int n, int *pMinPos){
	int i;
	*pMinPos=0;
	for(i=1; i<n; ++i){
		if(num[*pMinPos]>num[i]){
			*pMinPos=i;
		}
	}
	return num[*pMinPos];
}
int FindMax(int num[], int n, int *pMaxPos){
	int i;
	*pMaxPos=0;
	for(i=1; i<n; ++i){
		if(num[*pMaxPos]<num[i]){
			*pMaxPos=i;
		}
	}
	return num[*pMaxPos];
}

用例测试结果 运行时间 占用内存 提示 得分
用例1通过 1ms 256kb
2
用例2通过 1ms 256kb
2
提交答案本次得分/总分:4.00/4.00分

7杨辉三角形(4分)

题目内容:

编程打印具有如下形式的杨辉三角形,其中输出数据的行数n从键盘输入,并且n<=10。

程序运行结果示例1:

Input n (n<=10):

5↙

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

程序运行结果示例2:

Input n (n<=10):

7↙

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1

输入提示信息:“Input n (n<=10):\n”

输入格式: “%d”

输出格式:

输出数据格式:"%4d"

数据换行: “\n”

注意:为避免出现格式错误,请直接拷贝粘贴上面给出的输入、输出提示信息和格式控制字符串!

时间限制:500ms内存限制:32000kb
C

#include<stdio.h>
#define  ARR_SIZE  11
void  YH(int a[][ARR_SIZE], int  n);
void  PrintYH(int a[][ARR_SIZE], int  n);
int main(void)
{
	int n;
	printf("Input n (n<=10):\n");
	scanf("%d", &n);
    int  a[ARR_SIZE][ARR_SIZE];
    YH(a, n);
    PrintYH(a, n);
    return 0;
}
void YH(int a[][ARR_SIZE], int n)
{
        int  i, j ;
        for (i=0; i<n; i++)
        {  
             a[i][0] = 1;
             a[i][i] = 1;
        }
        for (i=2; i<n; i++)
        {
            for (j=1; j<=i-1; j++)
            {
                 a[i][j] = a[i-1][j-1] + a[i-1][j];
            }       
        }
}
void PrintYH(int a[][ARR_SIZE], int n)
{
    int i , j ;
    for (i=0; i<n; i++)
    {
        for (j=0; j<=i; j++)
        {
            printf("%4d", a[i][j]);
        }
         printf("\n");
    }
}

用例测试结果 运行时间 占用内存 提示 得分
用例1通过 1ms 256kb
2
用例2通过 2ms 256kb
2
提交答案本次得分/总分:4.00/4.00分

8颠倒句子中的单词顺序(4分)

题目内容:

从键盘输入一个句子(假设字符数小于100个),句子中的单词之间用空格分隔,句子必须以一个标点符号作为结尾,句子开头和末尾标点符号前均没有空格,以回车表示输入结束,请编程颠倒句中的单词顺序并输出。

函数原型:int Inverse(char str1[], char str2[][N])

程序运行结果示例1:

Input a sentence:you can cage a swallow can’t you?↙

you can’t swallow a cage can you?

程序运行结果示例2:

Input a string:you are my sunshine!↙

sunshine my are you!

程序运行结果示例3:

Input a sentence:I love you!↙

you love I!

输入提示信息:“Input a sentence:”

输入格式: 用gets()函数

输出格式:

每个单词的输出格式:"%s " (注意: %s后面有一个空格)

最后一个单词和标点符号的输出格式:"%s%c\n"

注意:为避免出现格式错误,请直接拷贝粘贴上面给出的输入、输出提示信息和格式控制字符串!

时间限制:500ms内存限制:32000kb
C

#include<stdio.h>
#define N 100
int Inverse(char str1[], char str2[][N]);
int isEnd(char c){
	if(c=='!' || c=='?' || c=='.') return 1;
	return 0;
}
int main(void)
{	
	int i;
	char end;
	printf("Input a sentence:");
	char str[100], ans[N][N];
	gets(str);
	for(i=0; str[i]!=0; ++i){
		if(isEnd(str[i])){
			end=str[i];
			str[i]=0;
		}
	}
	int len = Inverse(str, ans);
	for(i=len-1; i>0; --i){
		printf("%s ", ans[i]);
	}
	printf("%s%c\n", ans[0], end);
    return 0;
}

int Inverse(char str1[], char str2[][N]){
	int i, j=0, k=0;
	for(i=0; str1[i]!=0; ++i){
		k=0;
		while(str1[i]!=' ' && str1[i]!=0){
			str2[j][k++]=str1[i++];
		}
		str2[j][k]=0;
		j++;
	}
	return j;
}

用例测试结果 运行时间 占用内存 提示 得分
用例1通过 2ms 128kb
2
用例2通过 2ms 128kb
2
提交答案本次得分/总分:4.00/4.00分

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值