126 lines
2.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## C语言-1
```c
/*------------------------------------------------------------------------------
【程序设计】程序实现的功能是:输入字符串(不包含空格),删除其中的数字字符后输出。
输入输出如下:
hello 123 world
去掉数字后的字符串为hello world
------------------------------------------------------------------------
注意部分源程序给出如下。请勿改动主函数main或其它函数中给出的内容否则不得分。
仅在Program-End之间填入若干语句。不要删除标志否则不得分。
------------------------------------------------------------------------------*/
#include<stdio.h>
#include <string.h>
void main()
{
char a[100],b[100];
int l,i,j;
gets(a);
l=strlen(a);
j=0;
/**********Program**********/
for(i=0;i<l;i++){
if(a[i] > '9' || a[i] < '0'){
b[j++]=a[i];
}
}
/********** End **********/
b[j]='\0';
printf("去掉数字后的字符串为:");
puts(b);
}
```
## C语言-2
```c
/*------------------------------------------------------------------------------
【程序设计】输入一个整数k, S=1*2*3*…*n求S不大于k时最大的n。
------------------------------------------------------------------------
注意部分源程序给出如下。请勿改动主函数main或其它函数中给出的内容否则不得分。
仅在Program-End之间填入若干语句。不要删除标志否则不得分。
------------------------------------------------------------------------------*/
#include<stdio.h>
void main()
{
int i=1,k,s=1;
/**********Program**********/
scanf("%d", &k);
while(1){
if(s > k){
break;
}
i++;
s*=i;
}
i--;
/********** End **********/
printf("%d\n",i);
}
```
## MySQL
```sql
#1
ALTER TABLE t_hotel ADD `level` CHAR(10) DEFAULT '暂无评级';
#2
INSERT INTO t_hotel()
VALUES(DEFAULT, '苹果酒店', '无名街356号', '138-1258-0000', '五星');
#3
UPDATE t_room r
SET r.price = r.price+100
WHERE r.hid = (
SELECT hid
FROM t_hotel
WHERE hname = '香蕉酒店'
);
#4
SELECT c.cname, c.integral,
IF(c.integral<1000, '普通会员',
IF(c.integral<3000, '中级会员',
IF(c.integral<5000, '高级会员', '顶级会员')))
FROM t_client c;
#5
SELECT h.hid, ROUND(AVG(r.price), 2) p
FROM t_hotel h, t_room r
WHERE h.hid = r.hid
GROUP BY h.hid
ORDER BY p DESC;
#6
SELECT c.cid, c.cname, SUM(r.price) s
FROM t_client c, t_booking b, t_room r
WHERE c.cid = b.cid AND r.rid = b.rid
GROUP BY c.cid
ORDER BY s DESC
LIMIT 1;
#7
CREATE VIEW v_hotel AS
SELECT DATE_FORMAT(b.btime,'%Y-%m') d, SUM(r.price)
FROM t_booking b, t_room r
WHERE b.rid = r.rid
GROUP BY d;
#8
DELIMITER $$
CREATE TRIGGER tri_updateLevel
BEFORE UPDATE ON t_client
FOR EACH ROW
BEGIN
IF NEW.integral <2500 THEN
SET NEW.`level` = '初级会员';
ELSEIF NEW.integral <5000 THEN
SET NEW.`level` = '中级会员';
ELSE
SET NEW.`level` = '高级会员';
END IF;
END $$
DELIMITER ;
#9
```