C语言程序学习001大一

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int MaxNum(int x, int y)
{
	if (x>y)
		return x;
	else
		return y;
}

int SumNum(int x, int y)
{
	static int bbb = 0;//熟悉static的使用
	int c = 0;
	c = x + y;
	bbb = bbb + 1;               
	printf("第bbb=%d次计算加法\r\n", bbb);
	return c;
}

void DelayNum(int x)                                     
{
	int i = 0;
	for (i = 0; i<x; i++)
	{
		printf("i=%d\r\n", i);
	}
}

void while00()
{
	int i = 10;
	while (i)
	{
		i = i - 1;
	}
}

void Delay()
{
	int i = 0;
	for (i = 0; i<5; i++)
	{
		printf("i=%d\r\n", i);
	}
}

void main(int argc, char *argv[])
{
	int Snum = 0;
	int Max = 0;
	int x = 0;
	int y = 0;
	char c1 = 's';
	char c2 = 'S';

	Delay();
	printf("**********\r\n");
	DelayNum(8);
	printf("**********\r\n");
	Snum = SumNum(3, 5);
	printf(" a and b is %d\r\n", Snum);
	printf("**********\r\n");

	Max = MaxNum(8, 2);
	printf("The Max number is %d\r\n", Max);
	printf("**********\r\n");

	printf("Please input x,y\r\n");
	scanf_s("%d,%d", &x, &y);
	Snum = SumNum(x, y);
	printf("The sum number of a and b is %d\r\n", Snum);
	printf("**********\r\n");
	

	printf("Please input x,y\r\n");
	scanf_s("%d,%d", &x, &y);
	Snum = SumNum(x, y);
	printf("The sum number of a=%d and b=%d is %d\r\n",x,y,Snum);//多参数输出
	printf("**********\r\n");


	printf("c1=%c,c2=%c\r\n", c1, c2);
	printf("c1=%d,c2=%d\r\n", c1, c2);
	printf("c1=0x%x,c2=0x%x\r\n", c1, c2);
	while00();

	system("pause");
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值