浙大MOOC翁恺C语言程序设计课后习题

中国大学MOOC-翁恺-C语言程序设计习题集-解答汇总 中国大学MOOC-翁恺-C语言程序设计习题集 PAT 习题集 02-0. 整数四则运算(10) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 乔林(清华大学) 本题要求编写程序,计算2个正整数的和、差、积、商并输出。题目保证输入和输出全部在整型范围内。 输入格式: 输入在一行中给出2... 阅读详情

中国大学MOOC-翁恺-C语言程序设计习题集(学习笔记)

02-2. 然后是几点(15)

有时候人们用四位数字表示一个时间,比如1106表示11点零6分。现在,你的程序要根据起始时间和流逝的时间计算出终止时间。 读入两个数字,第一个数字以这样的四位数字表示当前时间,第二个数字表示分钟数,计算当前时间经过那么多分钟后是几点,结果也表示为四位数字。当小时为个位数时,没有前导的零,即5点30分表示为530。注意,第二个数字表示的分钟数可能超过60,也可能是负数。

输入格式:

输入在一行中给出2个整数,分别是四位数字表示的起始时间、以及流逝的分钟数,其间以空格分隔。注意:在起始时间中,当小时为个位数时,没有前导的零,即5点30分表示为530;流逝的分钟数可能超过60,也可能是负数。

输出格式:

输出四位数字表示的终止时间。题目保证起始时间和终止时间在同一天内。

输入样例:
1120 110
输出样例:
1310

#include<stdio.h>

int main(int argc, const char * argv[])
{
int time,add,hour,minute,hour1, minute1,a,b;

scanf("%d %d",&time,&add);

hour=time/100;
minute=time%100;
minute1=hour*60+minute+add;

hour1=minute1/60;
b=minute1%60;
a=hour1*100+b;
printf("%d",a);

}

03-1. 三天打鱼两天晒网(15)

中国有句俗语叫“三天打鱼两天晒网”。假设某人从某天起,开始“三天打鱼两天晒网”,问这个人在以后的第N天中是“打鱼”还是“晒网”?

输入格式:

输入在一行中给出1个不超过1000的正整数N。

输出格式:

在一行中输出此人在第N天中是“Fishing”(即“打鱼”)还是“Drying”(即“晒网”),并且输出“in day N”。

输入样例1:
103
输出样例1:
Fishing in day 103
输入样例2:
34
输出样例2:
Drying in day 34
#include <stdio.h>

int main()
{
int n;
scanf("%d", &n);

int t = n%5;
	if (t>=1 && t<=3){
	printf("Fishing in day %d\n", n);
} else{
	printf("Drying in day %d\n", n);
}
return 0;

}
03-3. 12-24小时制(15)
编写一个程序,要求用户输入24小时制的时间,然后显示12小时制的时间。

输入格式:

输入在一行中给出带有中间的“:”符号(半角的冒号)的24小时制的时间,如
12:34
表示12点34分。当小时或分钟数小于10时,均没有前导的零,如
5:6
表示5点零6分。

提示:在scanf的格式字符串中加入“:”,让scanf来处理这个冒号。

输出格式:

在一行中输出这个时间对应的12小时制的时间,数字部分格式与输入的相同,然后跟上空格,再跟上表示上午的字符串“AM”或表示下午的字符串“PM”。如“
5:6 PM
”表示下午5点零6分。注意,在英文的习惯中,中午12点被认为是下午,所以24小时制的
12:00
就是12小时制的
12:0 PM
;而0点被认为是第二天的时间,所以是
0:0 AM
。

输入样例:
21:11
输出样例:
9:11 PM
#include <stdio.h>

int main(int argc, const char * argv[])

{

int m,n;

scanf("%d:%d",&m,&n);

if (m>=0 && m<12) {

    printf("%d:%d AM\n",m,n);

}

else if (m==12){

    printf("%d:%d PM\n",m,n);

}

else if (m>12 && m<=24){  

    printf("%d:%d PM\n",m%12,n);

}

}

03-4. 成绩转换(15)
本题要求编写程序将一个百分制成绩转换为五分制成绩。转换规则:

大于等于90分为A;
小于90且大于等于80为B;
小于80且大于等于70为C;
小于70且大于等于60为D;
小于60为E。
输入格式:

输入在一行中给出1个整数的百分制成绩。

输出格式:

在一行中输出对应的五分制成绩。

输入样例:
90
输出样例:
A

#include <stdio.h>

int main()
{
int score;
scanf("%d",&score);
score /= 10;
switch (score){
case 10:
case 9:
printf(“A”);
break;
case 8:
printf(“B”);
break;
case 7:
printf(“C”);
break;
case 6:
printf(“D”);
break;

PTA上 然后是几点 问题解决与问题反思 问题如下: 7-14 然后是几点 (15 分) 有时候人们用四位数字表示一个时间,比如1106表示11点零6分。现在,你的程序要根据起始时间和流逝的时间计算出终止时间。 读入两个数字,第一个数字以这样的四位数字表示当前时间,第二个数字表示分钟数,计算当前时间经过那么多分钟后是几点,结果也表示为四位数字。当小时为个位数时,没有前导的零,即5点30分表示为530。注意,第二个数字表示的分钟数可能超过6... 阅读详情

相关推荐

C语言-翁恺-PTA-81-120课后练习题-03

title: C语言-翁恺-PTA-81-120课后练习题-0380-以后的题目感觉都不是很好做一个正整数N的因子中可能存在若干连续的数字。例如 630 可以分解为 3×5×6×7,其中 5、6、7 就是 3 个连续的数字。给定任一正整数N,要求编写程序求出最长连续因子的个数,并输出最小的连续因子序列。

Huangpengyu123的博客 1402

中国大学MOOC|C语言程序设计(浙江大学翁恺)|习题与解答

文章目录00-0. 题目02-0. 整数四则运算(10)02-1. 厘米换算英尺英寸(15)02-2. 然后是几点(15)02-3. 逆序的三位数(10)02-4. BCD解密(10)03-0. 超速判断(10)03-1. 三天打鱼两天晒网(15)03-2. 用天平找小球(10)03-3. 12-24小时制(15)03-4. 成绩转换(15)04-0. 求符合给定条件的整数集(15)04-1. 水...

weixin_42355492的博客 1万+

C语言学习笔记_MOOC浙大翁恺

文章目录第一周:程序设计与C语言1.1 计算机和编程语言1.3 第一个C程序第二周:计算2.1 变量2.2 表达式第三周:判断3.1 判断3.2 分支第四周:循环4.1 循环4.2 循环的应用习题解析第五周:循环控制5.1 第三种循环5.2 循环控制5.3 循环应用习题解析第六周:数据类型6.1 数据类型6.2 其他运算:逻辑、条件、逗号第七周:函数7.1 函数的定义和使用7.2 函数的参数和变量第八周:数组8.1 数组8.2 数组运算第九周:指针9.1 指针9.2 指针运算第十周:字符串10.1 字符串1

qq_40360775的博客 3546

中国大学MOOC 浙江大学 翁恺 程序设计入门(C) 自拟题解

第一章 //愿逃课侠同学程序人生一帆风顺~ #include <stdio.h> int main() { printf("Hello World"); return 0; } 第二章 #include <stdio.h> int main() { int n, a, b, c; scanf("%d", &n); a = n%10; b = n/10%...

weixin_43504742的博客 2552

从时频谱图到智能感知:雷达信号处理的AI进化之路

本文探讨了人工智能在雷达信号处理中的革命性应用,特别是深度学习在时频谱图分析中的突破性进展。通过对比传统信号处理方法与AI驱动的解决方案,展示了CNN、3D CNN等模型在目标检测、行为识别等场景中的优势,并分析了数据获取、模型优化等关键技术挑战。AI赋能的雷达技术已广泛应用于智能交通、工业检测和医疗健康领域,展现出巨大的发展潜力。

weixin_29284201的博客 515

实测对比:DECIMER、Img2Mol、MolScribe,哪个化学结构识别工具更靠谱?

化学结构识别(CSR)工具的核心任务是将分子结构图像转换为SMILES(Simplified Molecular Input Line Entry System)表示。这一过程需要克服图像质量差异、绘制风格变化以及特殊基团识别等挑战。三款工具采用不同的技术路线:DECIMER:基于EfficientNetV2+Transformer架构,优势在于处理标准期刊文献中的分子图示Img2Mol。

weixin_32576389的博客 353

qt使用qxlsx实现xlsx、xls表格文件快速写入和读取

新年第二篇文章,收尾一个去年计划中发表文章和实现功能。

kbq的博客 1万+

Python实战:超分辨率图像质量评估全攻略——PSNR、SSIM、LPIPS与NIQE的代码实现与优化

本文详细介绍了在Python中实现超分辨率图像质量评估的完整方案,涵盖PSNR、SSIM、LPIPS和NIQE四大核心指标。通过模块化代码设计、多进程并行处理和GPU加速优化,帮助开发者构建高效、可扩展的评估系统,并提供了实战避坑指南与结果解读方法。

weixin_29053073的博客 482

【详细】芯片设计全流程(包括每个流程需要用到的工具以及需要参与的工作人员)

一颗芯片的诞生经历了设计、制造和测试(分别对应集成电路产业链的设计业、制造业和封测业),而每一步都包含了复杂的步骤和流程。 图0-1 集成电路产业链 现在,我们重点介绍芯片设计的全流程以及每个流程需要用到的设计工具和需要参与的工作人员。 一、IC设计分类 首先对IC设计的分类做个介绍,如图1-1所示。 图1-1 IC设计分类 如图1-1所示,IC设计可以粗分为数字IC设计和射频/模拟IC设计,数字IC设计又可分为ASIC设计和FPGA/CPLD设计,此外还有一部分IC设计.

qq_36045093的博客 8万+

YOLOv11改进 - C3k2融合 | C3k2 融合 ARConv 自适应矩形卷积:动态调整卷积核形状与采样点

本文介绍了将自适应矩形卷积(ARConv)模块与YOLOv11相结合的方法。ARConv是针对遥感图像全色锐化任务设计的创新卷积模块,可自适应调整卷积核形状与采样点数量,解决传统卷积刚性限制,实现高效特征提取。其工作流程包括学习卷积核高度和宽度、选择采样点数量、生成采样图、卷积实现与空间自适应增强。我们将集成ARConv的C3k2_ARConv模块引入YOLOv11,对相关代码进行修改和注册,并配置了yolov11 - C3k2_ARConv.yaml文件。实验脚本显示,该结合方式应用于目标检测任务。

魔改工程师的博客 1016

PT:pt write_change to innovus 脚本

我正在「拾陆楼」和朋友们讨论有趣的话题,你⼀起来吧?

m0_61544122的博客 1538

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

下一篇: Docker删除镜像操作
小小酷儿
博客等级 码龄7年 2粉丝 12原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址