东华复试day16
OJ81
个人总结:利用字符串来保存浮点数
#include <stdio.h>
#include <string.h>
int main() {
char num[1000];
while (scanf("%s", &num) != EOF) {
int len = strlen(num);
int count = 0, found = 0;
for(int i = 0; i < len; i++){
if(num[i] == '.'){
found = 1;
continue;
}
if(found == 1){
count++;
}
}
printf("%d\n", count);
}
return 0;
}
OJ82
个人总结:利用字符串来保存进制转换的结果
#include <stdio.h>
#include <string.h>
#define MAX_SIZE 9999
int main(){
int m, n;
while(scanf("%d %d", &m, &n) != EOF){
char str[MAX_SIZE];
if(m == 0){
printf("0\n");
continue;
}
int temp = m, i = 0, result;
while(temp > 0){
result = temp % n;
if(result >= 10)
str[i++] = result - 10 + 'A';
else
str[i++] = result + '0';
temp /= n;
}
for(int j = i - 1; j >= 0; j--){
printf("%c", str[j]);
}
printf("\n");
}
return 0;
}
OJ83

个人总结:读入字符后先消除字符串里的空格再根据运算符计算结果
#include <stdio.h>
#include <string.h>
int main(){
char str[99];
while(fgets(str, sizeof(str), stdin) != NULL){
str[strcspn(str, "\n")] = '\0';
char str1[99];
int len = strlen(str), j = 0;
for(int i = 0; i < len; i++){
if(str[i] != ' ')
str1[j++] = str[i];
}
str1[j] = '\0';
int len1 = j, sum = 0, num = 0;
char op = '+'; //默认第一个操作为+
for (int i = 0; i < len1; i++){
if(isdigit(str1[i])){
//构建数字
num = num * 10 + (str1[i] - '0');
}else{
//遇到运算符
if(op == '+'){
sum += num;
}else if(op == '-'){
sum -= num;
}
//记录新的运算符
op = str1[i];
num = 0;
}
}
//处理最后一个数字
if(op == '+'){
sum += num;
}else if (op == '-'){
sum -= num;
}
printf("%d\n", sum);
}
return 0;
}
OJ84
个人总结:
fgets()用于读取字符串,可以包含空格,stdin代表键盘输入;strcspn(str, "\n")用于找到换行符的位置并替换为字符串结束符
2. 将字符串存储到字符数组 str[] 中,遍历字符数组,若字符数组的值等于要删除的字符值,则令字符数组中该值为 '\0',遍历完后输出该字符数组,跳过值为 '\0' 的位置
3. 要删除的字符被替换为 '\0',在输出时不能直接令 i < strlen(str),应该令 i < 原始长度 len,strlen(str) 看到 '\0'就认为字符串结束了,若使用 i < strlen(str),第二个循环中长度变短,无法完全遍历
#include <stdio.h>
#include <string.h>
int main(){
char str[20];
char c;
fgets(str, sizeof(str), stdin);//输入字符串(包含空格)
str[strcspn(str, "\n")] = '\0';//移除fgets可能读取的换行符并替换为字符串结束符
scanf("%c", &c);//输入要删除的字符
int len = strlen(str);
for(int i = 0; i < len; i++){
if(str[i] == c)
str[i] = '\0';
}
for(int i = 0; i < len; i++){
if(str[i] != '\0')
printf("%c", str[i]);
}
return 0;
}
Convolutional neural networks (CNNs) are among the most important models in deep learning and are widely used in computer vision tasks such as image classification, object detection, and image segmentation. Compared with traditional fully connected neural networks, CNNs significantly reduce the number of parameters by using local connections and weight sharing, which lowers computational complexity. Convolutional layers can automatically extract features from raw images, including edges, textures, and shapes. As the number of layers increases, the model is able to learn more abstract and complex feature representations. In addition, pooling layers are usually used to reduce the spatial dimensions of feature maps, thereby decreasing computational cost and improving robustness. In practical applications, CNNs have achieved remarkable success in areas such as medical image analysis, autonomous driving, and face recognition. However, training deep convolutional neural networks often requires large amounts of labeled data and powerful computing resources, which remains an important challenge in current research
卷积神经网络(CNNs)是深度学习领域最重要的模型之一,广泛应用于图像分类、目标检测、图像分割等计算机视觉任务。与传统的全连接神经网络相比,卷积神经网络通过局部连接和权值共享大幅减少了参数数量,从而降低了计算复杂度。卷积层能够从原始图像中自动提取特征,包括边缘、纹理和形状等;随着网络层数的增加,模型能够学习到更抽象、更复杂的特征表示。此外,池化层通常用于降低特征图的空间维度,进而减少计算成本并提升模型的鲁棒性。在实际应用中,卷积神经网络已在医学图像分析、自动驾驶、人脸识别等领域取得了显著成效。不过,训练深度卷积神经网络往往需要大量带标注的数据和强大的计算资源,这仍是当前研究中面临的一项重要挑战。
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐



所有评论(0)