认证考试第一题

namespace Test1_1
{
class Program
{
static void Main(string[] args)
{
int result = 0;
Console.WriteLine("请输入一个正整数:");
int n = int.Parse(Console.ReadLine());
if (n %2 == 0)//这里要注意  是求余运算  ,不能用“/”
{
for (int i = 0; i <= n;i+=2)
{

result += i;
}

}
else if(n%2!=0)
{
for (int i = 1; i <= n; i+=2)
{

result += i;
}
}
Console.WriteLine(result);
Console.ReadKey();
}
}
}

时间: 2024-08-05 07:18:15

认证考试第一题的相关文章

9.18考试 第一题count题解

这道题说起来挺可惜的,当时纠结是用常数大但有可能减少递归层数的模还是用常数小但递归多的回溯纠结了好半天,最终错误的选择了摸.导致T了20分,改成回溯就A了. 先分析一下性质,我在考试的时候打表发现在数据范围内因子最多有240个,因此有可能是通过枚举因子进行计算,然后如果说对于一个块他的确可以把一棵树分为几块方法只有一种(不要问我为什么,我也不知道怎么证,但的确如此)那么我们的最坏复杂度就是O(240*n),比理论最大复杂度还多了一倍,这也是为什么当时我自己预估60分的原因,然而这就很尴尬了,这的

【2019年8月版】OCP 071认证考试原题-第41题

choose three The ORDERS table has a primary key constraint on the ORDER_ID column. The ORDER_ITEMS table has a foreign key constraint on the ORDER_ID column,referencing the primary key of the ORDERS table. The constraint is defined with on DELETE CAS

【2019年8月版】OCP 071认证考试原题-第42题

Choose two Examine this SQL statement: DELETE FROM employees e WHERE EXISTS (SELECT 'dummy' FROM emp_history WHERE employee_id = e.employee_id) Which two are true? A) The subquery is executed for every row in the EMPLOYEES table. B) The subquery is n

9.5 考试 第一题 礼物题解

问题 A: 礼物 时间限制: 1 Sec  内存限制: 256 MB 题目描述 夏川的生日就要到了.作为夏川形式上的男朋友,季堂打算给夏川买一些生 日礼物. 商店里一共有种礼物.夏川每得到一种礼物,就会获得相应喜悦值Wi(每种 礼物的喜悦值不能重复获得). 每次,店员会按照一定的概率Pi(或者不拿出礼物),将第i种礼物拿出来. 季堂每次都会将店员拿出来的礼物买下来.没有拿出来视为什么都没有买到,也 算一次购买. 众所周知,白毛切开都是黑的.所以季堂希望最后夏川的喜悦值尽可能地高. 求夏川最后最大

9.16考试 第一题 X国的军队题解

这道题总体来看还是比较满意的.连想带打不超过半个小时,打了不到当时基本读懂后就感觉是贪心,但贪什么很重要,当时一开始想的是贪心死亡人数,从小到大搞,然后自己造了几个小数据,还好WA了,然后又列了一个式子,直接证明了贪心.式子如下: 我们设有两个据点,一个A=x1,B=y1,另一个A=x2,b=y2. 若x1-y1>x2-y2 则先打A所需为 x1+(x2-(x1-y1))=x2+y1,先打B为x2+(x1-(x2-y2))=x1+y2. 由上式可知x1+y2>x2+y1,所以应当先打A. 其余

C语言考试第一题详细过程

1.计算 ,并输出其结果. 思路是先设计一个函数计算阶乘,再用循环,逐个求和. #include<stdio.h> int mul(int n) { int num,i; num=1; for(i=1;i<=n;i++) num=num*i; return(num); } void main() { int i,sum=0; for(i=1;i<=10;i++) sum+=mul(i); printf("The sum is %d\n",sum); } 这个代码

【2019年8月版】OCP 071认证考试原题-第40题

Choose two. Which two statements are true about single row functions? A) CONCAT : can be used to combine any number of values B) MOD : returns the quotient of a division operation C) CEIL : can be used for positive and negative numbers D) FLOOR : ret

【2019年8月版】OCP 071认证考试原题-第39题

Choose two Exanine the desatption of the BOOKS_TRANSACTIONS table Name Null? Type TRANSACTION_ID NOT NULL VARCHAR2(6) TRANSACTION_TYPE VARCHAR2(3) BORROWED_DATE DATE BOOK_ID ARCHAR2(6) MEMBER_ID VARCHAR2(6) Examine this partial SQL statement: SELECT

【2019年8月版】OCP 071认证考试原题-第43题

Choose two. You execute this command: TRUNCATE TABLE depts; Which two are true? A) It drops any triggers defined on the table. B) It retains the indexes defined on the table. C) It retains the integrity constraints defined on the table. D) A ROLLBACR