主对角线和(填空)
作者: 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已经成为大型语言模型的理论基础,并继续推动人工智能的发展。