当前位置:网站首页>Take you to brush (niuke.com) C language hundred questions (the first day)
Take you to brush (niuke.com) C language hundred questions (the first day)
2022-07-07 06:49:00 【@Code every day】
Author's brief introduction : Hello, I'm @ Typing code every day , A player of material transcoding farmer , Hope to work together , Progress together !
Personal home page :@ Every day, I have to type the personal homepage of the code
Series column : Cattle from C Language question brushing column
Recommend a simulated interview 、 Brush Title artifact , From basic to interview questions Click to jump to the question brushing website to register for learning
Catalog
Exercise 2 : Print small aircraft
Exercise 3 : Niuniu talks -- Integers
Exercise 4 : Niuniu talks -- Floating point numbers
Exercise five : Niuniu talks -- character
Exercise 6 : The second integer of Niuniu
Preface
I believe most of you are from C Language starts basic programming ;C The saying that everything is born is not in vain ,C As the basis of programming 、 The starting point , Our most important thing is to cultivate a kind of programming thinking ; Then we need a platform to practice and consolidate after learning the knowledge points ; So today I'd like to recommend a magic question brush that I've been using , From basic grammar to interview questions , Everything is complete ; I don't say much nonsense , direct Login website Let's write the questions together !
Exercises 1 :Hello Nowcoder!
describe
Output "Hello Nowcoder!". Start your programming journey .
Examination site : The main test is to master basic grammar
Specific code :
#include <stdio.h>
int main()
{
printf("Hello Nowcoder!\n");
return 0;
}
Exercise 2 : Print small aircraft
describe
KiKi Learned to printf Output information on the screen , He wants to export a small plane . Please write a program for him to output this small plane .
Output description :
analysis : about printf Use and understanding of library functions , Note that you should remember to wrap every time you print (\n)
Specific code :
#include <stdio.h>
int main()
{
printf(" ** \n");
printf(" ** \n");
printf("************\n");
printf("************\n");
printf(" * * \n");
printf(" * * \n");
return 0;
}
Exercise 3 : Niuniu talks -- Integers
describe
Niuniu has just been born , cry piteously for food , At first he could only say simple numbers , You tell him an integer , He can learn at once .
Enter an integer , Output this integer .
Input description :
Enter an integer , The scope is 32 Bit signed integer range
Output description :
Output this integer , for example :
Input :3
Output :3
analysis : The main test is scanf The use of library functions , Note that the integer is %d, Don't forget to take the address of the variable (&)
Specific code :
#include <stdio.h>
int main()
{
int n = 0;
// Input integer n
scanf("%d",&n);
// Print integers n
printf("%d\n",n);
return 0;
}
Exercise 4 : Niuniu talks -- Floating point numbers
describe
Can say integer after , Niuniu began to try floating point numbers ( decimal )
Enter a floating point number , Output this floating point number .
Input description :
Enter a floating point number
Output description :
Output a floating point number , Keep three decimal places ; for example :
Input :1.359578
Output :1.360
analysis : For floating point number output and printing is %f, To keep n Decimal place , Need to be in %f Add milk in the middle .n, for example :%.nf
Specific code :
#include <stdio.h>
int main()
{
float a=0.0;
scanf("%f",&a);
printf("%.3f",a);
return 0;
}
Exercise five : Niuniu talks -- character
describe
After floating point numbers , Niuniu began to try characters
Enter a character , Output this character .
Input description :
Enter a character , The scope is ASCII Within the scope of
Output description :
Output this character
Input :a
Output :a
analysis : For character type output and printing is %c, You can also use getchar() Library function
Specific code :
#include <stdio.h>
int main()
{
//---------- Method 1:
char ch = 0;
scanf("%c",&ch);
printf("%c\n",ch);
//---------- Method 2: Use getchar() To get a character , Can return int You can also return char
int i = getchar();// Each character corresponds to ASCII Code value , therefore int Type reception is no problem
putchar(i);
return 0;
}
Exercise 6 : The second integer of Niuniu
describe
Niu Niu inputs three integers from the keyboard , And try to display the second integer on the screen .
Input description :
One line input 3 It's an integer , Space off .
Output description :
Please output the value of the second integer .
Input :1 2 3
Output :2
analysis : Print out the middle number , We can define an array to store these three numbers , Access with subscript ; You can also define three variables to store and print
Specific code :
#include <stdio.h>
int main()
{
//----------------- Method 1. Using arrays
int arr[3]={0};
int i=0;
// Input 3 Data
for(i=0;i<3;i++)
{
scanf("%d",&arr[i]);
}
// Print by subscript
printf("%d\n",arr[1]);
//----------------- Method 2. Definition 3 A variable
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
// Take out the middle data directly through variables
printf("%d",y);
return 0;
}
Conclusion
You have all the customers you want , All kinds of big factory interview questions are waiting for you ! Register and join the problem brushing army through the link below !
Brush Title artifact , From basic to interview questions Click to jump to the website
边栏推荐
- 品牌·咨询标准化
- docker-compose启动redis集群
- 精准时空行程流调系统—基于UWB超高精度定位系统
- mobx 知识点集合案例(快速入门)
- impdp的transform参数的测试
- 什么情况下考虑分库分表
- 途家、木鸟、美团……民宿暑期战事将起
- Data of all class a scenic spots in China in 2022 (13604)
- 如何给目标机器人建模并仿真【数学/控制意义】
- Pinduoduo lost the lawsuit: "bargain for free" infringed the right to know but did not constitute fraud, and was sentenced to pay 400 yuan
猜你喜欢
MATLAB小技巧(29)多项式拟合 plotfit
企业如何进行数据治理?分享数据治理4个方面的经验总结
化工园区危化品企业安全风险智能化管控平台建设四大目标
华为机试题素数伴侣
网络基础 —— 报头、封装和解包
POI export to excel: set font, color, row height adaptation, column width adaptation, lock cells, merge cells
Leite smart home longhaiqi: from professional dimming to full house intelligence, 20 years of focus on professional achievements
Leetcode T1165: 日志分析
[opencv] morphological filtering (2): open operation, morphological gradient, top hat, black hat
循环肿瘤细胞——Abnova 解决方案来啦
随机推荐
2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书第二阶段答案
Leetcode T1165: 日志分析
循环肿瘤细胞——Abnova 解决方案来啦
C language interview to write a function to find the first public string in two strings
Basic DOS commands
LM11丨重构K线构建择时交易策略
肿瘤免疫治疗研究丨ProSci LAG3抗体解决方案
Jmeter 5.5版本发布说明
Overview of FlexRay communication protocol
How to install swoole under window
Doctoral application | Professor Hong Liang, Academy of natural sciences, Shanghai Jiaotong University, enrolls doctoral students in deep learning
ceres-solver和g2o性能比较
二十岁的我4面拿到字节跳动offer,至今不敢相信
化工园区危化品企业安全风险智能化管控平台建设四大目标
品牌·咨询标准化
Prompt for channel security on the super-v / device defender side when installing vmmare
MySQL(十)
2022年全国所有A级景区数据(13604条)
impdp的transform参数的测试
地质学类比较有名的外文期刊有哪些?