C:\SVN\book\C\blog>cat even-1.c #include// 程式將 i 調整為偶數後再乘以 5 int main() { int i = 3; // 檢驗 i 是否為奇數 if (i % 2 == 1) // 沒失敗 i++; i *= 5; // 變成偶數後再乘以 5 printf("%d\n", i); } C:\SVN\book\C\blog>gcc even-1.c C:\SVN\book\C\blog>a.exe 20
2011年8月6日 星期六
4 * 5 = 20
4 * 5 = 15
C:\SVN\book\C\blog>cat even.c #include// 程式將 i 調整為偶數後再乘以 5 int main() { int i = 3; // 檢驗 i 是否為奇數 if (i % 2 == 1) // 成功 i++; i *= 5; // 變成偶數後再乘以 5 printf("%d\n", i); } C:\SVN\book\C\blog>gcc even.c C:\SVN\book\C\blog>a.exe 15
2011年8月4日 星期四
1 & 3 != 0
int main()
{
char i = 1;
char j = 3;
if (i & j)
printf("yes.\n");
else
printf("no.\n");
return 0;
}
Output
yes.
1 & 3 == 0
int main()
{
char i = 1;
char j;
scanf("%d", &j);
if (i & j)
printf("yes.\n");
else
printf("no.\n");
return 0;
}
Input
3
Output
no.
訂閱:
意見 (Atom)