教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 基础教育 >

C语言:基本控制结构(12)

来源:网络收集 时间:2026-04-30
导读: 'A's[0] if((s[i]>'a's[i] 'A's[i] '0's[i] 简单密码破解 Time Limit: 1000MS Memory limit: 65536K 题目描述 密码是我们生活中非常重要的东东,我们的那么一点不能说的秘密就全靠它了。哇哈哈. 接下来渊子要在密码
<'z')||(s[0]>'A'&&s[0]<'Z')||(s[0]=='_')) { for(i=1;i

if((s[i]>'a'&&s[i]<'z')||(s[i]>'A'&&s[i]<'Z')||(s[i]>'0'&&s[i]<'9')||s[i]=='_') flag=1; else { flag=0; break;//出现错误,跳出循环 } } } else flag=0; if(flag==0) printf(\ if(flag==1) printf(\ } }

简单密码破解

Time Limit: 1000MS Memory limit: 65536K

题目描述

密码是我们生活中非常重要的东东,我们的那么一点不能说的秘密就全靠它了。哇哈哈. 接下来渊子要在密码之上再加一套密码,虽然简单但也安全。

假设渊子原来一个BBS上的密码为zvbo941987,为了方便记忆,他通过一种算法把这个密码变换成YUANzi1987,这个密码是他的名字和出生年份,怎么忘都忘不了,而且可以明目张胆地放在显眼的地方而不被别人知道真正的密码。

他是这么变换的,大家都知道手机上的字母: 1--1, abc--2, def--3, ghi--4, jkl--5, mno--6, pqrs--7, tuv--8 wxyz--9, 0--0,就这么简单,渊子把密码中出现的小写字母都变成对应的数字,数字和其他的符号都不做变换,声明:密码中没有空格,而密码中出现的大写字母则变成小写之后往后移一位,如:X,先边成小写,再往后移一位,不就是y了嘛,简单吧。记住,z往后移是a哦。 输入

输入包括多个测试数据。输入是一个明文,密码长度不超过100个字符,输入直到文件结尾。 输出

输出渊子真正的密文。 示例输入 YUANzi1987 示例输出 zvbo941987

#include #include void main() { int i,l; char s[100]; scanf(\ l=strlen(s); for(i=0;i='A'&&s[i]<='Y') printf(\ if(s[i]=='Z') printf(\ if(s[i]>='0'&&s[i]<='9') printf(\ } }

闰年

Time Limit: 1000MS Memory limit: 32768K

题目描述

时间过得真快啊,又要过年了,同时,我们的人生也增长了一年的阅历,又成熟了一些。可是,你注意过今年是不是闰年呢,明年呢?

以上是闰年的计算方法的流程图,聪明的你能否通过编程计算任意给出的一个年份是否是闰年呢?相信这个问题你能很快解决掉。 输入

只有一个整数year,代表年份范围在1900~2060之间。 输出

如果是闰年输出Yes,否则输出No。 示例输入 2000 示例输出 Yes

#include void main() { int year; scanf(\ if((year%4==0&&year0!=0)||year@0==0) printf(\ else printf(\}

Friday the Thirteenth

Time Limit: 1000MS Memory limit: 65536K

题目描述

Is Friday the 13th really an unusual event?

That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute the frequency that the 13th of each month lands on Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday over a given period of N years. The time period to test will be from January 1, 1900 to December 31, 1900+N-1 for a given number of years, N. N is non-negative and will not exceed 400.

There are few facts you need to know before you can solve this problem:

? January 1, 1900 was on a Monday.

? Thirty days has September, April, June, and November, all the rest have 31 except for

February which has 28 except in leap years when it has 29.

? Every year evenly divisible by 4 is a leap year (1992 = 4*498 so 1992 will be a leap year,

but the year 1990 is not a leap year)

? The rule above does not hold for century years. Century years divisible by 400 are leap

years, all other are not. Thus, the century years 1700, 1800, 1900 and 2100 are not leap years, but 2000 is a leap year. Do not use any built-in date functions in your computer language. Don't just precompute the answers, either, please. PROGRAM NAME: friday

输入

there are several test cases, each have the following format: One line with the integer N.

输出 For each input, there is an output correspond to it, each have the following format: Seven space separated integers on one line. These integers represent the number of times the 13th falls on Saturday, Sunday, Monday, Tuesday, ..., Friday. 示例输入 20

示例输出

36 33 34 33 35 35 34

Geometry Made Simple

Time Limit: 1000MS Memory limit: 65536K

题目描述

Mathematics can be so easy when you have a computer. Consider the following example. You probably know that in a right-angled triangle, the length of the three sides a, b, c (where c is the longest side, called the hypotenuse) satisfy the relation a*a+b*b=c*c. This is called Pythagora's Law.

Here we consider the problem of computing the length of the third side, if two are given.

输入

The input contains the descriptions of several triangles. Each description consists of a line containing three integers a, b and c, giving the lengths of the respective sides of a right-angled triangle. Exactly one of the three numbers is equal to -1 (the 'unknown' side), the others are positive (the 'given' sides).

A description having a=b=c=0 terminates the input. 输出

For each triangle description in the input, first output the number of the triangle, as shown in the sample output. Then print \side lengths. Otherwise output the length of the 'unknown' side in the format \the name of the unknown side (a, b or c), and l is its length. l must be printed exact to three digits to the right of the decimal point.

Print a blank line after each test case. 示例输入 3 4 -1 -1 2 7 5 -1 3 0 0 0 示例输出

…… 此处隐藏:2124字,全部文档内容请下载后查看。喜欢就下载吧 ……
C语言:基本控制结构(12).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/565726.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)