OJ模拟5

主对角线和(填空)

作者: Turbo

时间限制: 1s

章节: 二维数组

问题描述

给定程序的功能是:先从键盘上输入一个3行3列矩阵的各个元素的值,然后输出主对角线(从左上到右下的对角线)元素之和。

请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。

注意:源程序如下。不得增行或删行,也不得更改程序的结构!

#include <stdio.h>

int main() {

int a[3][3], sum;

int i, j;

/*********found**********/

1;

for (i = 0; i < 3; i++) {

for (j = 0; j < 3; j++)

/*********found**********/

scanf("%d", 2);

}

for (i = 0; i < 3; i++)

/*********found**********/

sum = 3;

printf("Sum=%d\n", sum);

return 0;

}

输入说明

输入一个3*3的矩阵

输出说明

根据源程序所给格式输出

cpp 复制代码
#include <stdio.h>

int main() {

	int a[3][3], sum;

	int i, j;

	/*********found**********/

	sum=0;

	for (i = 0; i < 3; i++) {

		for (j = 0; j < 3; j++)

			/*********found**********/

			scanf("%d", &a[i][j]);

	}

	for (i = 0; i < 3; i++)

	    /*********found**********/

		sum = sum+a[i][i];

	printf("Sum=%d\n", sum);

	return 0;

}

修改信息(填空)

作者: Turbo

时间限制: 1s

章节: 结构体

问题描述

程序通过定义学生结构体变量,存储了学生的学号、姓名和3门课的成绩。

函数fun的功能是对形参b所指结构体变量中的数据进行修改,将学号加上10,姓名修改为"LiJie",最后在主函数中输出修改后的数据。

例如:b所指变量t中的学号、姓名、和三门课的成绩依次是:10002、"ZhangQi"、93、85、87,修改后输出t中的数据应为:10012、" LiJie"、93、85、87。

请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。

注意:源程序如下。

不得增行或删行,也不得更改程序的结构!

#include <stdio.h>

#include <string.h>

struct student {

long sno;

char name[10];

float score[3];

};

void fun(struct student b[]) {

/**********found**********/

b__1__ += 10;

/**********found**********/

strcpy(b__2__, "LiJie");

}

int main() {

struct student t;

int i;

scanf("%d%s%f%f%f", &t.sno, &t.name, &t.score[0], &t.score[1], &t.score[2]);

/**********found**********/

fun(3);

printf("No: %ld Name: %s\nScores: ", t.sno, t.name);

for (i = 0; i < 3; i++)

printf("%6.2f ", t.score[i]);

printf("\n");

return 0;

}

输入说明

输入以下五个数据:

一个正整数表示学号、一个字符串表示姓名、三个正整数表示成绩

输出说明

根据源程序所给格式输出

cpp 复制代码
#include  <stdio.h>

#include  <string.h>

struct student {

         long sno;

         char name[10];

         float score[3];

};

void fun(struct student b[]) {

         /**********found**********/

         b->sno += 10;

         /**********found**********/

         strcpy(b->name, "LiJie");

}

int main() {

         struct student t;

         int i;

         scanf("%d%s%f%f%f", &t.sno, &t.name, &t.score[0], &t.score[1], &t.score[2]);

         /**********found**********/

         fun(&t);

         printf("No: %ld Name: %s\nScores: ", t.sno, t.name);

         for (i = 0; i < 3; i++)

                   printf("%6.2f ", t.score[i]);

         printf("\n");

        return 0;

}

年龄最大(填空)

作者: Turbo

时间限制: 1s

章节: 结构体

问题描述

给定程序中,函数fun的功能是:将形参std所指结构体数组中年龄最大者的数据作为函数值返回,并在main函数中输出。

请在程序的下划线处填入正确的内容并把下划线删除,使程序得出正确的结果。

注意:源程序如下。

不得增行或删行,也不得更改程序的结构!

#include <stdio.h>

typedef struct {

char name[10];

int age;

} STD;

STD fun(STD std[], int n) {

STD max;

int i;

/**********found**********/

max = 1;

for (i = 1; i < n; i++)

/**********found**********/

if (max.age < 2)

max = std[i];

return max;

}

int main() {

STD std[5];

int i;

for (i = 0; i < 5; ++ i) {

scanf("%s%d", &std[i].name, &std[i].age);

}

STD max;

max = fun(std, 5);

/**********found**********/

printf("Name : %s, Age : %d\n", 3, max.age);

return 0;

}

输入说明

输入5行, 每行有一个字符串和一个正整数, 表示姓名和年龄

输出说明

根据源程序所给格式输出

cpp 复制代码
#include <stdio.h>

typedef struct {

         char name[10];

         int age;

} STD;

STD fun(STD std[], int n) {

         STD max;

         int i;

         /**********found**********/

         max = std[0];

         for (i = 1; i < n; i++)

                   /**********found**********/

                   if (max.age < std[i].age)

                            max = std[i];

         return max;

}

int main() {

         STD std[5];

        int i;

        for (i = 0; i < 5; ++ i) {

                   scanf("%s%d", &std[i].name, &std[i].age);

         }

         STD max;

         max = fun(std, 5);

         /**********found**********/

         printf("Name : %s, Age : %d\n", max.name, max.age);

         return 0;

}

英语翻译

The Transformer model has revolutionized natural language processing by introducing the self-attention mechanism. Unlike recurrent neural networks, Transformers process input sequences in parallel, which greatly improves computational efficiency. The self-attention mechanism enables the model to assign different weights to different words in a sentence, capturing long-range dependencies effectively. Multi-head attention further enhances the model's ability to learn diverse representations. In addition, positional encoding is used to incorporate sequence order information. Transformer-based models, such as BERT and GPT, have achieved state-of-the-art performance in tasks like machine translation, text generation, and question answering. Due to their scalability, Transformers have become the backbone of large language models and continue to drive advancements in artificial intelligence.

Transformer模型通过引入自我注意机制彻底改变了自然语言处理。与递归神经网络不同,Transformers并行处理输入序列,大大提高了计算效率。自我注意机制使模型能够为句子中的不同词赋予不同的权重,有效捕捉远距离依赖关系。多头注意力进一步增强了模型学习不同表示的能力。此外,位置编码用于包含序列顺序信息。基于变压器的模型,如BERT和GPT,在机器翻译、文本生成和问题回答等任务中取得了最先进的性能。由于其可伸缩性,Transformers已经成为大型语言模型的理论基础,并继续推动人工智能的发展。

相关推荐
算法鑫探21 小时前
闰年判断:C语言实战解析
c语言·数据结构·算法·新人首发
WBluuue21 小时前
数据结构与算法:康托展开、约瑟夫环、完美洗牌
c++·算法
木子墨51621 小时前
LeetCode 热题 100 精讲 | 并查集篇:最长连续序列 · 岛屿数量 · 省份数量 · 冗余连接 · 等式方程的可满足性
数据结构·c++·算法·leetcode
2501_921960851 天前
双相自指图与弦论边界非对易性的结构同源
数据结构
王老师青少年编程1 天前
csp信奥赛C++高频考点专项训练之贪心算法 --【线性扫描贪心】:均分纸牌
c++·算法·编程·贪心·csp·信奥赛·均分纸牌
EQUINOX11 天前
2026年码蹄杯 本科院校赛道&青少年挑战赛道提高组初赛(省赛)第一场,个人题解
算法
萝卜小白1 天前
算法实习Day04-MinerU2.5-pro
人工智能·算法·机器学习
Liangwei Lin1 天前
洛谷 P3133 [USACO16JAN] Radio Contact G
数据结构·算法
weixin_513449961 天前
PCA、SVD 、 ICP 、kd-tree算法的简单整理总结
c++·人工智能·学习·算法·机器人
code_pgf1 天前
Qwen2.5-VL 算法解析
人工智能·深度学习·算法·transformer