各种语句及编程笔记记录

1.if & else

#include<stdio.h>

int main(){

    int

if (situation)

{

        //model;

}

else

 {

        //mode2;

}

prinf("?\n")

    return 0;

}


2.if & else(a>60)

#include<stdio.h>

int main()

{

    int a=100;

if (a > 60)

{

        printf("a\n");

}

else

 {

        printf("b\n");

    }

    return 0;

}

 

    


3.hello world

#include <stdlib.h>

int main()

{

    printf("Hello world!\n");

    return 0;

}


4.if&else 嵌套char c

#include<stdio.h>

int main()

{

    int a=100;

    char c;

if (a >= 60)

{

        c = 'a';

}

else

 {

        c = 'd';

    }

    printf("%c\n", c);

    return 0;

}

    


5.多层if

#include<stdio.h>

int main()

{

    int a=100;

    char c;

if (a >= 90)

{

        c = 'a';

    }

if (a >= 80 && a < 90)

{

        c = 'b';

    }

if (a >= 60 && a < 80)

{

        c = 'c';

    }

if (a >= 0 && a < 60)

{

        c = 'd';

    }

    printf("%c\n", c);

    return 0;

}

    


6.if&else多层嵌套

#include<stdio.h>

int main()

{

    int mark = 100;

    char grade;

if (mark >= 90)

{

        grade = 'a';

    }

else

 {

        if (mark >= 70)

        {

            grade = 'b';

        }

         else

         {

            if (mark >= 60){

                grade = 'c';

            }

            else

            {

                grade = 'd';

            }

        }

    }

    printf("%c\n", grade);

    return 0;

}


7.区分等级abcd

#include<stdio.h>

int main()

{

    int a=100;

    char c;

    if (a >= 90)

    {

        c = 'a';

    }

    else if (a >= 80 && a < 90)

    {

        c = 'b';

    }

    else if (a >= 60 && a < 80)

    {

        c = 'c';

    }

    else

    {

        c = 'd';

    }

    printf ("%c\n", c);

    return 0;

}

    


8.1+2+3+4+…+99+100=5050

#include<stdio.h>

int main(){

    int i, s;

    s = 0;

    for (i = 1; i <= 100; i++)

    {

        s = s + i;

    }

    printf("%d\n", s);

    return 0;

}


9.1*2*3*…*9*10=3628800

#include<stdio.h>

int main()

{

    int i, s;

    s = 1;

    for (i = 1; i <= 10; i++)

    {

        s = s * i;

 

    }

    printf("%d\n", s);

    return 0;

}


10.1+2+3+...+n

#include<stdio.h>

int main()

{

    int i, s, n;

    scanf("%d", &n);

    s = 0;

    for (i = 1; i <= n; i++)

    {

        s = s + i;

 

    }

    printf("%d\n", s);

    return 0;

}

   


11.用户输入十个同学的成绩

全部转化为abcd四个等级

#include<stdio.h>

int main()

{

    int i, n;

    for (i = 0; i <= 10; i++)

    {

        scanf("%d", &n);

        if(n >= 90)

        {

            printf("A\n");

            }else

            {

                if(n >= 75)

                {

                    printf("B\n");

                    }else

                    {

                        if(n >= 60)

                        {

                            printf("C\n");

                            }else

                            {

                                printf("D\n");

                            }

                    }

            }

    }

     return 0;

}

    


12.标注

Int  main(){} 运行主体

scanf(“”,&); 输入

printf(“?\n”); 输出

int a    //“%d\n, a”   整数型

float b  //“%f\n, b”   浮点型

char c  //“%c\n, c”    字符

// 注释

\n 回收符

#include<stdio.h>

C语言学习记录之二的更多相关文章

  1. Lua和C++交互 学习记录之二:栈操作

    主要内容转载自:子龙山人博客(强烈建议去子龙山人博客完全学习一遍) 部分内容查阅自:<Lua 5.3  参考手册>中文版 译者 云风 制作 Kavcc vs2013+lua-5.3.3 1 ...

  2. Go语言学习笔记十二: 范围(Range)

    Go语言学习笔记十二: 范围(Range) rang这个关键字主要用来遍历数组,切片,通道或Map.在数组和切片中返回索引值,在Map中返回key. 这个特别像python的方式.不过写法上比较怪异使 ...

  3. 我的hibernate学习记录(二)

    通过上一篇文章我的hibernate学习记录(一)基本上的入门了hibernate,但是,里面还有还多东西是通过迷迷糊糊的记忆,或者说copy直接弄进去的,所以这篇文章就需要对上篇的一些文件.对象进行 ...

  4. 我的Spring学习记录(二)

    本篇就简单的说一下Bean的装配和AOP 本篇的项目是在上一篇我的Spring学习记录(一) 中项目的基础上进行开发的 1. 使用setter方法和构造方法装配Bean 1.1 前期准备 使用sett ...

  5. 我的three.js学习记录(二)

    通过上一篇文章我的three.js学习记录(一)基本上是入门了three.js,但是这不够3D,这次我希望能把之前做的demo弄出来,然后通过例子来分析操作步骤. 1. 示例 上图是之前做的一个dem ...

  6. redis入门学习记录(二)

    继第一节 redis入门学习记录(一)之后,我们来学习redis的基本使用. 接下来我们看看/usr/local/redis/bin目录下的几个文件作用是什么? redis-benchmark:red ...

  7. 我的Spring Boot学习记录(二):Tomcat Server以及Spring MVC的上下文问题

    Spring Boot版本: 2.0.0.RELEASE 这里需要引入依赖 spring-boot-starter-web 这里有可能有个人的误解,请抱着怀疑态度看. 建议: 感觉自己也会被绕晕,所以 ...

  8. R语言学习记录(二)

    4.对象改值 4.1.就地改值 比如: vec <- c(0,0,0,0,0,0,0) vec[1]<-100 #vec向量的第一个值就变为100 ####对于数据框的改值的方法,如下面的 ...

  9. Go语言学习笔记(二)十分钟上手

    加 Golang学习 QQ群共同学习进步成家立业工作 ^-^ 群号:96933959 变量&常量 变量 变量名由字母.数字.下划线组成,不能以数字开头. ... var ( A int //默 ...

随机推荐

  1. 如何入门vue之一

    入门vue 首先从vue的指令开始学起. vue的指令: v-if  根据是否得到的布尔值进行是否显示. v-show:根据是否得到的布尔值是否显示.不同的地方在于隐藏是style隐藏. v-on 监 ...

  2. HashMap深度解析(转载)

    原文地址:http://blog.csdn.net/ghsau/article/details/16890151 实现原理:用一个数组来存储元素,但是这个数组存储的不是基本数据类型.HashMap实现 ...

  3. JavaScript charAt() 方法

    <script> var str="abcdef"; alert(str[0]); //a,高版本浏览器兼容 alert(str.charAt(0)); //a,兼容所 ...

  4. windows环境下protobuf的java操作{编译,序列化,反序列化}

    google protocol buffer的使用和原理 概况: Protocol Buffers(也就是protobuf)是谷歌的语言中立的.平台中立的.可扩展的用于序列化结构化的数据: windo ...

  5. prop与attr

    1.都是获取当前元素某个属性的值 2.当获取多选框的状态时,如果没有选中,此时没有checked属性,用attr获取得到undifien prop得到false. 3.html原生属性用prop获取, ...

  6. WPF实现Windows资源管理器(附源码)

      今天我来写一篇关于利用WPF来实现Windows的资源管理器功能,当然只是局部实现这个功能,因为在很多时候我们需要来实现对本机资源的管理,当然我们可以使用OpenFileDialog dialog ...

  7. Yii2框架GridView自带导出功能最佳实践

    1. 导出excel的实现方法 (1)使用phpexcel封装工具类导出excel (2)使用爬虫爬取页面再处理封装工具类导出excel (3)使用页面渲染后处理html添加头部信息生成excel文件 ...

  8. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0'

    七月 05, 2018 10:26:54 上午 org.apache.tomcat.util.digester.SetPropertiesRule begin警告: [SetPropertiesRul ...

  9. Lodop打印连续的纸张

    连续的纸张,有时有会被误解为没有高度,高度自适应,其实不是,这属于纸张连续打印,纸张高度和实际单个纸张高度相同.纸张高度自适应适用于没有高度的那种小票打印(卷纸没有纸张分界线),不是这种连续纸张.关于 ...

  10. Announcing Windows Template Studio in UWP

    今天,我们很高兴地宣布您的文件→新的通用Windows平台应用程序在Visual Studio - Windows模板工作室中的下一个演变.Windows Template Studio在开发人员调查 ...