当前位置:网站首页>c语言编程题
c语言编程题
2022-07-02 06:34:00 【懵懂的梦花火】
#include "stdafx.h"
#include <stdio.h>
#include <malloc.h>
int main(int argc, char* argv[])
{
int i, number, *p;
scanf("%d", &number); // 输入向量长度
p = (int*)malloc(sizeof(int)*number*2); // 申请长度为number个int的连续存储空间
printf("请输入长度为%d的两个向量:\n",number);
for (i = 0; i < number*2; i++)
{
scanf("%d", &p[i]); // 获取输入流中的数据(以int进行解析)
}
int result = 0;
// 计算向量内积
for (i = 0; i < number; i++)
{
result+= (p[i] * p[i+number]);
}
printf("result is %d\n", result);
return 0;
}
#include "stdafx.h"
#include <stdio.h>
#include <malloc.h>
struct RowMin
{
int value;
int row;
int col;
};
int main(int argc, char* argv[])
{
int i, number, *p;
scanf("%d", &number);
p = (int*)malloc(sizeof(int)*number*number); // 申请内存空间n*n长度
printf("请输入长度为%d*%d的数组:\n",number,number);
for (i = 0; i < number*number; i++)
{
scanf("%d", &p[i]);
}
// 找出每一行的最小值
RowMin *pRowMin = (RowMin*)malloc(sizeof(RowMin)*number); // 存储每一行的最小值
for (i = 0; i < number; i++)
{
pRowMin[i].value = p[number*i];
pRowMin[i].row = i;
pRowMin[i].col = 0;
for (int j = 1; j < number; j++)
{
if (p[number*i+j] < pRowMin[i].value)
{
pRowMin[i].value = p[number*i+j];
pRowMin[i].col = j;
}
}
}
// 找出每一行的最大值
int max = 0;
for (i = 1; i < number; i++)
{
if (pRowMin[max].value < pRowMin[i].value)
{
max = i;
}
}
printf("result is %d,%d,%d\n", pRowMin[max].value, pRowMin[max].row, pRowMin[max].col);
return 0;
}
边栏推荐
- [staff] common symbols of staff (Hualian clef | treble clef | bass clef | rest | bar line)
- Enterprise level SaaS CRM implementation
- Methods of classfile
- [staff] time mark and note duration (staff time mark | full note rest | half note rest | quarter note rest | eighth note rest | sixteenth note rest | thirty second note rest)
- Who is better for Beijing software development? How to find someone to develop system software
- 机器学习之数据类型案例——基于朴素贝叶斯法,用数据辩男女
- AMQ 4043 solution for errors when using IBM MQ remote connection
- Demand delineation executive summary
- Chrome用户脚本管理器-Tampermonkey 油猴
- 数构(C语言--代码有注释)——第二章、线性表(更新版)
猜你喜欢
数构(C语言)——第四章、矩阵的压缩存储(下)
十年開發經驗的程序員告訴你,你還缺少哪些核心競爭力?
微服务实战|负载均衡组件及源码分析
In depth analysis of how the JVM executes Hello World
Pool de connexion redis personnalisé
Microservice practice | fuse hytrix initial experience
Matplotlib swordsman Tour - an artist tutorial to accommodate all rivers
Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
[staff] common symbols of staff (Hualian clef | treble clef | bass clef | rest | bar line)
Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
随机推荐
VIM operation command Encyclopedia
Mathematics in machine learning -- point estimation (I): basic knowledge
Chrome browser plug-in fatkun installation and introduction
How to use pyqt5 to make a sensitive word detection tool
How to choose between efficiency and correctness of these three implementation methods of distributed locks?
Actual combat of microservices | discovery and invocation of original ecosystem implementation services
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
自定义Redis连接池
Mysql 多列IN操作
Watermelon book -- Chapter 6 Support vector machine (SVM)
ClassFile - Attributes - Code
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
In depth analysis of how the JVM executes Hello World
Microservice practice | fuse hytrix initial experience
C语言之数据插入
[staff] the lines and spaces of the staff (the nth line and the nth space in the staff | the plus N line and the plus N space on the staff | the plus N line and the plus N space below the staff | the
洞见云原生|微服务及微服务架构浅析
Chrome video download Plug-in – video downloader for Chrome
长篇总结(代码有注释)数构(C语言)——第四章、串(上)
Matplotlib剑客行——没有工具用代码也能画图的造型师