常量变量以及循环

来源:互联网 发布:知行论坛北交大登录 编辑:程序博客网 时间:2024/06/06 00:24

常量

1.三目运算词

三字母词 表达字符 ???( [ ??) ] ??< { ??> }

2.循环

1).数组元素以及变量在内存中的分配顺序

若不注意,会造成数组越界

2)goto语句应用

//电脑关机程序#include<stdio.h>#include <stdlib.h>#include <string.h>#include <windows.h>int main(){    char input[10] = { 0 };    flag:    system("shutdown -s -t 60");    printf("电脑将在1分钟关机,如果输入我是猪,就取消关机\n");    scanf("%s", input);    if (0 == (strcmp(input, "我是猪")))    {        system("shutdown -s");    }    else    {        goto flag;    }    return 0;}

3)break,continue在循环中作用

   break直接跳出循环,continue跳出本次循环执行下次循环

原创粉丝点击