当前位置:网站首页>C language programming problems
C language programming problems
2022-07-02 09:39:00 【Ignorant dream fireworks】
#include "stdafx.h"
#include <stdio.h>
#include <malloc.h>
int main(int argc, char* argv[])
{
int i, number, *p;
scanf("%d", &number); // Enter the vector length
p = (int*)malloc(sizeof(int)*number*2); // Application length is number individual int Of continuous storage space
printf(" Please enter a length of %d Two vectors of :\n",number);
for (i = 0; i < number*2; i++)
{
scanf("%d", &p[i]); // Gets the data in the input stream ( With int To analyze )
}
int result = 0;
// Compute the inner product of a vector
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); // Apply for memory space n*n length
printf(" Please enter a length of %d*%d Array of :\n",number,number);
for (i = 0; i < number*number; i++)
{
scanf("%d", &p[i]);
}
// Find the minimum value of each line
RowMin *pRowMin = (RowMin*)malloc(sizeof(RowMin)*number); // Store the minimum value of each row
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;
}
}
}
// Find the maximum value of each row
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;
}
边栏推荐
- TD conducts functional simulation with Modelsim
- Methods of classfile
- 图像识别-数据增广
- Amq6126 problem solving ideas
- Elastic Stack之Beats(Filebeat、Metricbeat)、Kibana、Logstash教程
- Don't look for it. All the necessary plug-ins for Chrome browser are here
- 上班第一天的报错(AWVS卸载不彻底)
- TD联合Modelsim进行功能仿真
- MySQL error: unblock with mysqladmin flush hosts
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedd
猜你喜欢
三相并网逆变器PI控制——离网模式
Enterprise level SaaS CRM implementation
PI control of grid connected inverter (grid connected mode)
Knowledge points are very detailed (code is annotated) number structure (C language) -- Chapter 3, stack and queue
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
Number structure (C language) -- Chapter 4, compressed storage of matrices (Part 2)
Pool de connexion redis personnalisé
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
Chrome user script manager tempermonkey monkey
Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
随机推荐
Typora installation package sharing
QT QLabel样式设置
MySQL error: unblock with mysqladmin flush hosts
Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)
Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer
Watermelon book -- Chapter 6 Support vector machine (SVM)
Beats (filebeat, metricbeat), kibana, logstack tutorial of elastic stack
保存视频 opencv::VideoWriter
Probability is not yet. Look at statistical learning methods -- Chapter 4, naive Bayesian method
Who is better for Beijing software development? How to find someone to develop system software
2837xd 代码生成——StateFlow(3)
攻防世界-Web进阶区-unserialize3
在SQL注入中,为什么union联合查询,id必须等于0
Safety production early warning system software - Download safety production app software
Web security and defense
vs+qt 设置应用程序图标
图像识别-数据清洗
zk配置中心---Config Toolkit配置与使用
Typeerror: X () got multiple values for argument 'y‘
FragmentTabHost实现房贷计算器界面