摘要:
例题 3-1 Tex中的引号 在TeX中,左引号是”””,右引号是““”。输入一篇包含双引号的文章,你的任务是把它转换成TeX的格式。 样例输入: “To be or not to be,”quoth the Bard,”that is the question”. 样例输出:... 阅读全文
摘要:
习题 3-4 竖式问题 找出所有形如abc*de(三位数乘以两位数)的算式,使得在完整的竖式中,所有数字都属于一个特定的数字集合。输入数字集合(相邻数字之间没有空格),输出所有竖式。每个竖式前应有编号,之后应有一个空行。最后输出解的总数。具体格式见样例输出(为了便于观察,竖式中的空格改用小数点显示... 阅读全文
摘要:
程序 3-1 将不超过100个数逆序输出#includeint main(){ int const MAXN = 105; int a[MAXN]; int n = 1, x = 0; // //注意头疼的边界问题 // whil... 阅读全文
摘要:
习题 2-1 打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身。 例如:153是一个“水仙花数”,因为153=13+53+33。程序 2-1#includeint main(){ int i = 100; while (i int main(){... 阅读全文
摘要:
例2-4 阶乘之和 输入n,计算S = 1! + 2! +3! +……+ n!的末6位(不含前导0)。n int main(){ int n; scanf("%d", &n); int sum = 0; int i = 1; while (i #includeint ... 阅读全文
摘要:
例题 2-2 3n+1问题 猜想:对于任意大于1的自然数n若n为奇数,则将n变为3n+1,否则变为n的一半。经过若干次的变换,一定会使n变为1。 例如3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 ->1。 输入n,输出变换的次数。n int main(){ int ... 阅读全文
摘要:
程序 2-1 输出1,2,3,4,5,……,n的值#includeint main(){ int n; scanf("%d", &n); int i = 1; for (; i #includeint main(){ int a, b; for (a = 1; a... 阅读全文
摘要:
例题 1-4 鸡兔同笼 已知鸡和兔的总数量为n, 总腿数为m。输入 n 和 m,依次输出鸡的数目和兔的数目。如果无解,输出No answer 样例输入: 14 32 样例输出: 12 2 样例输入: 10 16 样例输出: No answer【分析】 简单的数学问... 阅读全文