当前位置:网站首页>Niuke net question brushing training (I)
Niuke net question brushing training (I)
2022-07-26 02:01:00 【Wind rises and falls】
List of articles
Preface
I've heard a long time ago that This is one of the major websites necessary for question brushing Today I finally used
The more you use it, the more addictive you become , All the used ones are said to be good
Go in here and have a look — Cattle from

1.printf Return value
describe
KiKi Write an output “Hello world!” The program ,BoBo The teacher told him printf Function has return value , You can write him a program output printf(“Hello world!”) Return value of ?
Input description :
nothing
Output description :
It includes two lines :
First act “Hello world!”
Second behavior printf(“Hello world!”) The return value after the call .
#include<stdio.h>
int main()
{
printf("\n%d",printf("Hello world!"));
return 0;
}

The problem seems simple But it is not Need to know printf The return value of the function is the number of printed characters
First, the output Hello world!
Hello world! share 12 individual
printf(“%d",12);
Because the title requires two lines of output So in %d prefix \n
2. Civil service interview
describe
Civil servant interview on-site scoring . Yes 7 Examiner , Enter several groups of grades from the keyboard , Each group 7 A score ( Percentage system ), Take out the highest score and the lowest score , Output the average score of each group .
( notes : There are many groups of input )
Input description :
Every line , Input 7 It's an integer (0~100), representative 7 Achievements , Separate... With spaces .
Output description :
Every line , Output the average score excluding the highest and lowest scores , After the decimal point 2 position , Wrap after output of each line .
Example 1
Input :
99 45 78 67 72 88 60
Output :
73.00
#include<stdio.h>
int main()
{
int i=0;
int s=0;
int max=0;
int min=100;
int sum=0;
int count=0;
while(scanf("%d",&s)!=EOF)
{
count++;
sum=sum+s;
if(s>max)
{
max=s;
}
if(s<min)
{
min=s;
}
if(count==7)
{
printf("%.2f\n",(sum-max-min)/5.0);
count=0;
sum=0;
max=0;
min=100;
}
}
return 0;
}

A problem that must be paid attention to in this problem is :( notes : There are many groups of input )
So we have to adopt while loop The way
Used here count To calculate the number of points passed
Be equal to 7 Output when , And set the maximum value minimum value Record the total quantity count count Should be restored to the original value
When outputting, you should also pay attention to Divide two integers Will round off the decimal So add .0 Convert it to decimal
3. Character Christmas tree
describe
Enter a character , Use it to construct a side length of 5 A triangular Christmas tree .
Data range : Ensure that the input character is a char Type value
Input description :
There is only one line of input , A character .
Output description :
This character forms a triangular Christmas tree .
#include<stdio.h>
int main()
{
int N=0;
scanf("%c",&N);
int i=0;
int j=0;
for(i=0;i<5;i++)
{
for(j=0;j<5-1-i;j++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
printf("%c ",N);
}
printf("\n");
}
return 0;
}

This problem is divided into several parts
First of all, we need to Build to build a triangle Based on side length 5 example
1
1 1
1 1 1
1 1 1 1
1 1 1 1 1
2: We will find that The difference with the requirements of the topic is only on the blank
The first row is only inferior to the leftmost row 4 A space —N-1
The second row is only inferior to the leftmost row 3 A space —N-2
That is to say N-1-i A space
4. Insert a number in an ordered sequence
describe
There is an ordered sequence of numbers , Sort from small to large , Insert a newly entered number into the sequence , Ensure that after inserting a new number , The sequence is still in ascending order .
Input description :
Enter an integer in the first line (0≤N≤50).
Second line input N An integer in ascending order , Enter space delimited N It's an integer .
On the third line, enter an integer you want to insert .
Output description :
Output as a line ,N+1 An ordered integer .
Input :
5
1 6 9 22 30
8
Output :
1 6 8 9 22 30
#include<stdio.h>
int main()
{
int N=0;
scanf("%d",&N);
int arr[40]={
0};
int i=0;
for(i=0;i<N;i++)
{
scanf("%d",&arr[i]);
}
int tmp=0;
scanf("%d",&tmp);
for(i=N-1;i>=0;i--)
{
if(arr[i]>tmp)
{
arr[i+1]=arr[i];
}
else
{
arr[i+1]=tmp;
break;
}
}
if(i==-1)
{
arr[0]=tmp;
}
for(i=0;i<=N;i++)
{
printf("%d ",arr[i]);
}
return 0;
}

The main idea of this question is Compare the inserted numbers from back to front
If the number in the array is larger than the number inserted Then assign the number in the array backward
If the number in the array is smaller than the number inserted Then put the inserted number in the last digit of the current array
for example :
If 8 Less than 30 30 Pass back Move the array forward one bit
If 8 Greater than 6 Will 8 Insert 6 The last one of them
5.x Shape patterns
describe
KiKi I learned the cycle ,BoBo The teacher gave him a series of printing exercises , The task is to print “” Composed of X Shape patterns .
Input description :
Multi group input , An integer (2~20), Represents the number of rows output , It also means composition “X” The length of the backslash and the backslash of .
Output description :
Enter... For each line , For output “” Composed of X Shape patterns .
#include<stdio.h>
int main()
{
int i=0;
int j=0;
int N=0;
while(scanf("%d",&N)!=EOF)
{
for(i=0;i<N;i++)
{
for(j=0;j<N;j++)
{
if(i==j||i+j==N-1)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
}
return 0;
}

If you want to understand this problem Will know How did it come
First, we regard it as a square
List subscripts in order
This is what we found that the left underline is good i== j That is to say Rows are equal to columns
The right underline is i+j ==N-1 The addition of rows and columns is any minus 1
Other assignments are blank
summary
From Cattle from The exercises of
I believe it will be beneficial to learning c Language is more interesting , Let's go
Less confident friends can take a look at this training
边栏推荐
- JS add random pixel noise background to the page
- Implementation of C iterator
- i.MX6ULL SNVS电源域GPIO状态保持验证
- [in simple terms, play with FPGA learning 11 --- testbench writing skills 2]
- [C language brush leetcode] 814. Binary tree pruning (m)
- Niuke - bm39 serialized binary tree [hard]
- Worthington nuclease and Micrococcus related research and determination scheme
- Worthington产气荚膜梭菌神经氨酸酶的特征及测定
- 【2021】【论文笔记】6G技术愿景——OTFS调制技术
- 【2020】【论文笔记】磁控溅射法生长Bi2Te3/CoFeB双层异质结——
猜你喜欢

SQLyog数据导入导出图文教程
![[independent station construction] Shopify seller: learn these points and double the sales volume of online stores!](/img/52/8c1520db38ffa8927e975b6f244a65.png)
[independent station construction] Shopify seller: learn these points and double the sales volume of online stores!

SVN version control branch and merge function use

i.MX6ULL SNVS电源域GPIO状态保持验证
![Niuke - bm39 serialized binary tree [hard]](/img/c4/f14fe8488bbf28689fa3f02cdf4dae.png)
Niuke - bm39 serialized binary tree [hard]

Worthington产气荚膜梭菌神经氨酸酶的特征及测定

How to use the pagoda panel to deploy the full stack project of node to the server
![[paper reading] coat: CO scale conv attentional image transformers](/img/d4/13ac8cdce07999d4fd51aa23173190.png)
[paper reading] coat: CO scale conv attentional image transformers

Worthington nuclease and Micrococcus related research and determination scheme

还在用==0 null equal 判断空值吗,对isEmpty 和 isBlank有多少了解呢
随机推荐
Excuse me, sir. Oracle to PG CDC Oracle, the upper case of the field is the same as that of PG
Dest0g3 520 orientation (under update)
[C language brush leetcode] 735. Planetary collision (m)
When everything can be metauniverse, the development of metauniverse seems to have entered a new stage of development
Phoenix中常用shell操作
推荐系统-协同过滤在Spark中的实现
Add an interceptor to resttemplate to record the request response, and you also need to solve the problem that the flow is read only once
The detailed knowledge summary of MySQL can be collected
Ti AM335X工控模块矩阵键盘电路的设计与驱动移植
excel中怎么显示数字/英文时间
Characteristics and determination of neuraminidase from Clostridium perfringens in Worthington
Characteristics and determination of neuraminidase from Clostridium perfringens in Worthington
How idea can quickly delete recently opened projects
【独立站建设】shopify卖家:学会这几点,网上商店销量翻倍!
[in simple terms, play with FPGA learning 11 --- testbench writing skills 1]
Installing and using R in Anaconda
[C language brush leetcode] 146. LRU cache (m)
【深入浅出玩转FPGA学习11----Testbench书写技巧1】
DialogRPT-Dialog Ranking Pretrained Transformers
[C language brush leetcode] 814. Binary tree pruning (m)



