当前位置:网站首页>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;
}
边栏推荐
- Mysql默认事务隔离级别及行锁
- 每天睡前30分钟阅读Day6_Day6_Date_Calendar_LocalDate_TimeStamp_LocalTime
- vs+qt 设置应用程序图标
- 道阻且长,行则将至
- Mathematics in machine learning -- point estimation (I): basic knowledge
- tinyxml2 读取和修改文件
- 企业级SaaS CRM实现
- FragmentTabHost实现房贷计算器界面
- Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
- Activity的创建和跳转
猜你喜欢

Supplier selection and prequalification of Oracle project management system

Say goodbye to 996. What are the necessary plug-ins in idea?

2837xd code generation - Summary

Oracle modify database character set

TD conducts functional simulation with Modelsim

Read 30 minutes before going to bed every day_ day4_ Files

上班第一天的报错(AWVS卸载不彻底)

Probability is not yet. Look at statistical learning methods -- Chapter 4, naive Bayesian method

Machine learning practice: is Mermaid a love movie or an action movie? KNN announces the answer

PI control of three-phase grid connected inverter - off grid mode
随机推荐
PI control of three-phase grid connected inverter - off grid mode
Creation and jump of activity
2837xd Code Generation - stateflow (4)
Customize redis connection pool
From concept to method, the statistical learning method -- Chapter 3, k-nearest neighbor method
道阻且长,行则将至
Chrome浏览器插件-Fatkun安装和介绍
How to use PHP spoole to implement millisecond scheduled tasks
Difference between redis serialization genericjackson2jsonredisserializer and jackson2jsonredisserializer
BugkuCTF-web16(备份是个好习惯)
Navicat 远程连接Mysql报错1045 - Access denied for user ‘root‘@‘222.173.220.236‘ (using password: YES)
JVM instruction mnemonic
Who is better for Beijing software development? How to find someone to develop system software
Read 30 minutes before going to bed every day_ day3_ Files
Redis installation and deployment (windows/linux)
Operation and application of stack and queue
ZK configuration center -- configuration and use of config Toolkit
Microservice practice | teach you to develop load balancing components hand in hand
FragmentTabHost实现房贷计算器界面
QT qlabel style settings