C语言入门第一章

一、hello world /函数printf使用/

#include<stdio.h>
int main()
{
    printf("helllo world\n");
        return 0;
}

/ #include<stdio.h> 开头调用程序库 头文件 /

int main()
{
    printf("helllo world\n");                  主函数
        return 0;
}

 

//求最大者
#include<stdio.h> //头文件
int main()          //主函数
{
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    if(a>b)c=a;
    else c=b;
    printf("最大值是:%d",c);
    return 0;
}
 

//求最大者 函数调用

//定义函数叫行参 主函数叫实参
#include<stdio.h> //头文件
int main()          //主函数

{
    int max(int x,int y);
    int a,b,c;
    scanf("%d,%d",&a,&b);
    c = max(a,b);
    printf("max=%d\n",c);
    return 0;
}
int max(int x,int y)
{
    int z;
    if(x > y)z = x;
    else z = y;
    return(z);
}
 

 一个源程序文件 现在

多个函数 必须要有一个主函数 main

三部分 预处理 声明 主函数

//求和 
//函数调用 定义函数叫行参 主函数叫实参
#include<stdio.h> //头文件
int main()          //主函数

{
    int sum(int x,int y);
    int a,b,c;
    scanf("%d,%d",&a,&b);
    c = sum(a,b);
    printf("sum=%d\n",c);
    return 0;
}
int sum(int x,int y)
{
    int z;
    z = x+y;
    return(z);
}
 

二、算法

                            

算法+数据结构=程序

//连乘 
#include<stdio.h> 
int main()          

{
    int p = 1,i = 2;
    while(i<=5)
    {
        p = p*i;
        i = i+1;
    }
    printf("%d",p);
    return 0;
}


//
//流程图 表示算法 如何表示算法 流程图 NS图

                       

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值