iPhone第二天之C基础
今天我们主要说的还是C的基础,这次我们主要由代码来具体说明。首先来说说最头疼的问题a=i++与a=++i的区别,a=i++是先赋值再自增,a=++i是先自增再赋值
int i = 5;
int b = i++;
int c = i;
printf("b = %d\n",b);
printf("c = %d\n",c);
int a = ++i + (b++);
printf("a = %d\n",a);
printf("b = %d\n",b);
int d = i+b;
printf("d = %d\n",d);
printf("**********************\n");
int z=1;
int j =z++;
//j=1 z=2
printf("z = %d",z);
printf("j = %d\n",j);
j = ++z;
//j=3 z=3
printf("z = %d",z);
printf("j = %d\n",j);
j = z--;
//j=3 z=2
printf("z = %d",z);
printf("j = %d\n",j);
j = --z;
//j=1 z=1
printf("z = %d",z);
printf("j = %d\n",j);
printf("**********************\n");
任何语言都会用到判断的,下面先说说if else
printf("**********************\n");
i = 0;
if(i){
printf("true\n");
}else{
printf("false\n");
}
printf("**********************\n\n\n\n\n");
不使用中间值判断三个数最大的
printf("**********************\n\n\n\n\n");
a = 8;
b = 4;
c = 1;
int max = 0;
if(a>b){
if(a>c){
max = a;
}else{
max = c;
}
}else{
if(b<c){
max = c;
}else{
max = b;
}
}
printf("最大:%d\n",max);
printf("**********************\n\n\n");
switch语句
printf("**********************\n\n\n");
char char_grade;
printf("请输入:");
//scanf("%c",&char_grade);
switch(char_grade){
case 'A':
printf("90-100\n");
break;
case 'B':
printf("80-90\n");
break;
case 'C':
printf("70-80\n");
break;
default:
printf("请重新输入输入:\n");
break;
}
printf("**********************\n\n\n");
作者 10-3G-程龙
补充:移动开发 , IOS ,