C语言程序设计题3道

来源:百度知道 编辑:UC知道 时间:2024/05/24 04:10:33
老师给了这3道题目说可能考试有出,麻烦各位大哥帮我把详细的过程写出来,感激不尽啊~
程序设计题
1、 输入3个字符串,查找最小字符串并输出该字符串。
2、 输入一个由字母组成的字符串,再分别以大些字母和小写字母形式输出该字符串。
3、 编程实现,将任意给定的一个字符数组中下标值为奇数的元素从大到小排列,其它元素不变。

什么时候要,如果在就联系一下我吧

第一题:
#include<stdio.h>
#include<string.h>
#define N 40
void main()
{
char str1[N],str2[N],str3[N],str4[N];
int i=0;
printf("input string1: ");
scanf("%s",str1);
printf("input string2: ");
scanf("%s",str2);
printf("input string3: ");
scanf("%s",str3);
if(strcmp(str1,str2)>0)
strcpy(str4,str2);
else
strcpy(str4,str1);
if(strcmp(str3,str4)>0)
printf("The smallest string is %s\n",str4);
else if(strcmp(str3,str4)==0)
printf("The smallest string is %s\n",str4);
else
printf("Not the smallest string\n");
}

//第二道 不知道为什么不可以匿名提交了
//
#include <stdio.h>
void main()
{
char string[20];
char *p;
printf("Please input a string:");
sca