一,ifelse语句的细节
**语法:**ifelse语句是就近原则 的使用
/*************************************************************************
> File Name:
> Author: songli
> Mail:
> Created Time:
************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argc, char *argv[])
{
int y = 2;
if (y)
printf("11\n");
if (y > 2)
printf("21\n");
else //ifelse语句是就近原则 的使用
printf("12\n");
printf("\n");
system("pause");
return EXIT_SUCCESS;
}
二,while语句的使用语法
while的语法:使用时候和for的有i++的区别
/*************************************************************************
> File Name:
> Author: songli
> Mail:
> Created Time:
************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argc, char *argv[])
{
float value;
while (scanf("%f", &value) == 1 /*判断是否输入值了*/ && value >= 0)
{
printf("chensong\n");
}
char ch;
while ((ch = getchar()) != EOF && ch != '\n' /*有回车键时就退出*/)
{
printf("chensong\n");
}
int x = 4;
3 * x * x - 4 * x + 6;
printf("\n");
system("pause");
return EXIT_SUCCESS;
}
三,& ,^,| 使用的解说
语法的解说:
计算过程
00101110
& 01011011 and
00001010
00101110
^ 01011011 xor
01110101
00101110
| 01011011 or
00001010
/*************************************************************************
> File Name:
> Author: songli
> QQ:2734030745
> Mail: 15850774503@163.com
> Created Time:
************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argc, char *argv[])
{
int i = 90;
int y = i ^ 4; //xor
printf("y = %d\n", y);
int w = i | y; //or 1111111111111
printf("w = %d\n", w);
int j = y & i;
printf("j = %d\n", j);
//赋值
printf("\n");
system("pause");
return EXIT_SUCCESS;
}