c语言代码编程题汇总:找出三个数据中最大的数值

找出三个数据中最大的数值

  程序代码如下:

 1 /*
 2     2017年3月9日12:04:37
 3     功能:找出三个数据中最大的数值
 4 */
 5 #include"stdio.h"
 6
 7 int fun(int,int,int);
 8
 9 int main()
10 {
11     int a ,b,c;
12
13     printf("please input three number: \n");
14
15     scanf("%d %d %d",&a,&b,&c);
16
17     printf("the maxium number is %d\n",fun(a,b,c));
18
19 }
20
21 int fun(int a,int b,int c)
22 {
23     if(a-b > 0 && a -c >0)
24         return a;
25     else if(b-a > 0 && b - c > 0)
26         return b;
27     else
28         return c;
29 }
30 /*
31     总结:
32     在VC++6.0中显示的结果:
33     ————————————————————
34     please input three number:
35     23 45 67
36     the maxium number is 67
37     ————————————————————
38
39 */
时间: 2024-08-02 18:54:45

c语言代码编程题汇总:找出三个数据中最大的数值的相关文章

c语言代码编程题汇总:将三个随机的三个数按从大到小输出

将三个随机的三个数按从大到小输出 程序代码如下: 1 /* 2 2017年3月12日17:55:24 3 功能:将三个随机的三个数按从大到小输出 4 */ 5 #include"stdio.h" 6 void fun(int ,int ,int ); 7 void fun1(int , int ); 8 int main() 9 { 10 int a,b,c; 11 printf("please input three number :"); 12 scanf(&q

c语言代码编程题汇总:找出字符串中与输入的字母元素相同的个数以及其所对应数组的下标值

找出字符串中与输入的字母元素相同的个数以及其所对应数组的下标值 程序代码如下: 1 /* 2 2017年3月8日08:39:16 3 功能:找出字符串中与输入的字母元素相同的个数以及其所对应数组的下标值 4 */ 5 6 #include"stdio.h" 7 int main (void) 8 { 9 int i = 0, j = 0; 10 char a[100]; 11 char ch; 12 int num = 0; 13 14 printf ("please inp

c语言代码编程题汇总: 求出一个随机数的阶乘,采用for循环实现

  求出一个随机数的阶乘,采用for循环实现 采用随机数的算法,程序更加灵活,程序代码如下: 1 /* 2 2017年3月5日10:10:46 3 功能:求出一个随机数的阶乘,采用for循环实现 4 */ 5 6 #include "stdio.h" 7 int main (void) 8 { 9 int i, n; 10 int m = 1; 11 12 printf ("请输入所求n的数值: "); 13 scanf ("%d",&n

c语言代码编程题汇总:统计学生的分数,计算出低于平均值的人数

统计学生的分数,计算出低于平均值的人数 程序代码如下: 1 /* 2 2017年3月9日11:51:28 3 功能:统计学生的分数,计算出低于平均值的人数 4 */ 5 #include"stdio.h" 6 int main (void) 7 { 8 int i = 0, j; 9 int score; 10 float sum = 0.0, aver = 0.0; 11 int m = 0, k = 0; 12 int a[100]; 13 int b[100]; 14 15 16

c语言代码编程题汇总 :从键盘上输入一个整数n,输出斐波纳猰数列——自己打的代码

从键盘上输入一个整数n,输出斐波纳猰数列 程序代码如下: 1 /* 2 2017年3月5日10:35:17 3 功能:n的阶乘采用的是递归方式实现 4 */ 5 6 #include "stdio.h" 7 long fun(int n) //注意此处的fun()是调用函数,两者之间没有空格 8 { 9 if (n > 1) //此处跳出递归的条件是当n = 1时 10 return (n * fun(n -1)); //当n的值满足条件或n = 2时程序还会执行该条语句 11

c语言代码编程题汇总:将字符串中的大写字母转换成小写字母

将字符串中的大写字母转换成小写字母 程序代码如下: 1 /* 2 2017年3月8日21:21:46 3 功能:将字符串中的大写字母转换成小写字母 4 */ 5 /* 6 #include"stdio.h" 7 8 int main() 9 { 10 int n = 0; 11 12 char a[100]; 13 14 printf("please input a string:"); 15 16 gets(a); 17 18 for(int i = 0 ;a[i

c语言代码编程题汇总 :统计字符串中的大写和小写字母的个数

统计字符串中的大写和小写字母的个数 程序代码如下: 1 /* 2 2017年3月6日19:42:21 3 功能:统计字符串中的大写和小写字母的个数 4 */ 5 6 #include "stdio.h" 7 void fun (char *,int *,int *); 8 9 int main (void) 10 { 11 int m = 0,n = 0; 12 int *Pm = &m, *Pn = &n; 13 char s[100]; 14 printf (&qu

C语言代码编程题汇总:显示表达式1*2+3*4+...+9*10的表示形式

显示表达式1*2+3*4+...+9*10的表示形式 源程序代码如下: 1 /* 2 2017年6月7日22:54:51 3 功能:实现1*2+3*4+...+9*10表达式的操作 4 5 */ 6 #include "stdio.h" 7 #include "string.h" 8 9 char a[100]; 10 int i, j = 0; 11 int main() 12 { 13 for(i = 1; i <= 10; i++) 14 { 15 if

c语言代码编程题汇总:升序,奇数在前,偶数在后

升序,奇数在前,偶数在后 自己的代码: 1 /* 2 2017年3月14日12:52:39 3 功能:升序,奇数在前,偶数在后 4 */ 5 #include "stdio.h" 6 int main () 7 { 8 int j = 0, k = 0; 9 int a[10]; 10 int b[10]; 11 int c[10]; 12 int *pa = a; 13 14 printf("please input 10 number: \n"); 15 for