5.11 wertyu
// 5.1.1 wertyu
#include char *s = "1234567890-=qwertyuiop\\asdfghjkl;'zxcvbnm,./";
int main(void)
return 0;
}
5.1.2 tex括號
// 5.1.2 tex括號
#include int main(void)
else
printf("%c", c);
} return 0;
}
5.1.3 週期串
// 5.1.3 週期串
#include #include int main(void)
if(ok)
}}
5.2 高精度運算
5.2.1 小學生算術
// 5.2.1 小學生算術
#include int main(void)
printf("%d\n", ans);
} return 0;
}
5.2.2 階乘的精確值
// 5.2.2 階乘的精確值
#include #include #define maxn 3000
int f[maxn];
/*const int maxn = 3000;
int f[maxn];
這樣寫會報錯
.c|6|error: variably modified 'f' at file scope|
因為const在c中定義的時可讀變數,maxn依舊是變數,不能用變數宣告陣列長度
*/int main(void)
} for(j = maxn-1; j >= 0; j--)
if(f[j])
break;
for(i = j; i >= 0; i--)
printf("%d", f[i]);
printf("\n");
return 0;
}
演算法競賽入門經典第五章
例 5.1.3 週期串 fgets str,max,stdin scanf s str fgets 函式執行後,str會讀到 n 符號停下,也就是提取一行,n 也被讀進字串,因此strlen str 會比原本輸入的字串多乙個 除了一種很特殊的情況,讀入一行時,只一行並不是以 n 結束,而是以eof結...
演算法競賽入門經典 第五章 6174
假設你有乙個各位數字互不相同的四位數,把所有數字從大到小排序後得到a,從小到大排序後得到b,然後用a b替換原來這個數,並且繼續操作。例如,從1234出發,依次可以得到4321 1234 3087,8370 378 8352,8352 2358 6174,有趣的是,7641 1467 6174,回到...
演算法競賽入門經典 第五章錯位輸出
include char s 1234567890 qwertyuiop asdfghjkl zxcvbnm,int main return 0 記錄下標還可以當條件滿足的時候退出,這樣迴圈變數就一定是符合要求d 的下標值 要是我我會這麼寫 include char s 1234567890 qwe...