ios学习记录 day1
C语言
1. =是赋值符 ==是等于
2.a=b++;等价于a=b;b=b+1; a=++b;等价于b=b+1;a=b;
作业:
1.使用printf输出 *
***
*****
int main (int argc, const char * argv[])
{
{ printf(" *\n ***\n *****\n");
}
return 0;
}
2.输入两个数,打印 和 差 商 积 余数。
int main (int argc, const char * argv[])
{
{printf("请输入两个数:");
int a = 0,b = 0;
scanf("%d,%d",&a,&b);
printf("a+b=%d\n",a + b);
printf("a-b=%d\n",a - b);
printf("a*b=%d\n",a * b);
printf("a/b=%d\n",a / b);
printf("a%%b=%d\n",a % b);
}
return = 0;
}
3.控制台输出%
int main(int argc, const char * argv[])
{printf("%%\n");
return 0;
}
4.(面试题)输入一个字节内的数(0~255)和移动位数,输出移位结果,要求循环输出。
int main(int argc, const char * argv[])
{ unsigned char a = '\0',b = '\0';
int i = 0,j = 0,x = 0,move = 0;
printf("输入一个数和移动位数:");
scanf("%d,%d",&x,&move);
a = (char) x;
i = a >> move;
j = a << (8 - move);
b = i | j;
printf("移位后的结果:%d\n",b);
return 0;
}