当前位置:网站首页>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;
}
边栏推荐
- Microservice practice | Eureka registration center and cluster construction
- [go practical basis] how to set the route in gin
- Mysql默认事务隔离级别及行锁
- 每天睡前30分钟阅读Day5_Map中全部Key值,全部Value值获取方式
- Bold prediction: it will become the core player of 5g
- CKEditor 4.10.1 上传图片提示“不正确的服务器响应” 问题解决
- What is the function of laravel facade
- 微服务实战|手把手教你开发负载均衡组件
- Solutions to Chinese garbled code in CMD window
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
猜你喜欢
Ora-12514 problem solving method
[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
企业级SaaS CRM实现
Statistical learning methods - Chapter 5, decision tree model and learning (Part 1)
Matplotlib剑客行——没有工具用代码也能画图的造型师
Cloudrev self built cloud disk practice, I said that no one can limit my capacity and speed
上班第一天的报错(AWVS卸载不彻底)
How to install PHP in CentOS
Chrome用户脚本管理器-Tampermonkey 油猴
知识点很细(代码有注释)数构(C语言)——第三章、栈和队列
随机推荐
别找了,Chrome浏览器必装插件都在这了
[staff] common symbols of staff (Hualian clef | treble clef | bass clef | rest | bar line)
Dix ans d'expérience dans le développement de programmeurs vous disent quelles compétences de base vous manquez encore?
上班第一天的报错(Nessus安装winpcap报错)
Hystrix implements request consolidation
Chrome browser tag management plug-in – onetab
个人经历&&博客现状
Oracle delete tablespace and user
VIM operation command Encyclopedia
Chrome video download Plug-in – video downloader for Chrome
《统计学习方法》——第五章、决策树模型与学习(上)
Attributes of classfile
Chrome user script manager tempermonkey monkey
Statistical learning methods - Chapter 5, decision tree model and learning (Part 1)
Chrome browser plug-in fatkun installation and introduction
Chrome用户脚本管理器-Tampermonkey 油猴
[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
记录一下初次使用Xray的有趣过程
Matplotlib swordsman - a stylist who can draw without tools and code
Matplotlib剑客行——容纳百川的艺术家教程