当前位置:网站首页>Basic exercises of C language
Basic exercises of C language
2022-07-27 14:32:00 【South wind fahaxiki】
Topic 1 : Yes 1、2、3、4 A digital , How many different and unrepeated three digit numbers can be formed ? How many are they ?
#include<stdio.h>
int main()
{
int i,j,k,l=0;
printf(" subject : Yes 1、2、3、4 A digital , How many different and unrepeated three digit numbers can be formed ? How many are they ?\n");
for(i=1;i<5;i++) { // Here's a triple cycle
for(j=1;j<5;j++) {
for(k=1;k<5;k++){
if(i!=k&&k!=j&&i!=j){
printf("%d,%d,%d\n",i,j,k);
l+=1;
}
}
}
}
printf(" Altogether %d That's ok ",l);
}Topic two : seek 100-999 All the daffodils in the book , So-called “ Narcissistic number ” A three digit number , The sum of its cubes is equal to the number itself .
#include <stdio.h>
int main(){
int a,i,j,k;
for(a=100;a<1000;a++){
i = a/100%10;
j = a/10%10;
k = a%10;
if(k*k*k+j*j*j+i*i*i==a){
printf("%d\n",a);
}
}
}Topic three : Enter the date of the year , Judge how many days have passed in this year by this day ?
#include <stdio.h>
int main()
{
int year,month,day,sum;
printf(" Please enter the date , The format is 2022,3,28\n");
scanf("%d,%d,%d",&year,&month,&day);
switch(month){
case 1:sum=0;break;
case 2:sum=31;break;
case 3:sum=59;break;
case 4:sum=90;break;
case 5:sum=120;break;
case 6:sum=151;break;
case 7:sum=181;break;
case 8:sum=212;break;
case 9:sum=243;break;
case 10:sum=273;break;
case 11:sum=304;break;
case 12:sum=334;break;
default:printf(" Month error ");break;
}
sum=sum+day;
/* Detect whether it is a leap month */
if(year%400==0 || year%4==0 && year%100!=0){
if(month > 2){
sum = sum + 1;
}
}
printf("%d Year ended %d month %d The day passed altogether %d God ",year,month,day,sum);
return 0;
}Topic four : Programming calculation 100 to 999 How many numbers between , The sum of the figures is 5 .
#include <stdio.h>
int main(){
/*i For hundreds ,j by 10 position ,k For a bit */
int i,j,k,num;
for (num=100;num<999;num++){
i = num/100;
j = num /10 % 10;
k = num % 10;
if(i+j+k == 5){
printf("%d\n",num);
}
}
printf(" end ");
return 0;
}
And that's all for today , Remember to praise the collection , Share and forward , Pay attention to the little brother ! Last , If you want to learn or are learning C/C++ Programming , You can join Xiaobian Programming learning C/C++ Penguin circle
边栏推荐
- Docker实践经验:Docker 上部署 mysql8 主从复制
- MySQL advanced II. Logical architecture analysis
- One of yolox improvements: add CBAM, Se, ECA attention mechanism
- Windows10 installing SQL Server 2019
- spark job 使用log4j appender 追加日志到本地文件或者mysql
- 知识关联视角下金融证券知识图谱构建与相关股票发现
- 面向流行性疾病科普的用户问题理解与答案内容组织
- How to make computers have public IP
- 网上券商APP开户安全有保障吗?
- What open source projects of go language are worth learning
猜你喜欢

Dako held a meeting for the biological IPO: the annual revenue was 837million, and Wu Qingjun and his daughter were the actual controllers

uniapp的request数据请求简单封装步骤
![[popular science] the difference and connection between accuracy and resolution](/img/12/efcce1f6b8801d8d8b08b79818632c.png)
[popular science] the difference and connection between accuracy and resolution

面向流行性疾病科普的用户问题理解与答案内容组织

第3章业务功能开发(添加线索备注,自动刷新添加内容)

Ten thousand words detailed Google play online application standard package format AAB

线程知识总结

Mining enterprise association based on Enterprise Knowledge Map

Slam overview Reading Note 7: visual and visual intangible slam: state of the art, classification, and empirical 2021

Chinese character style transfer --- antagonistic discriminative domain adaptation (L1)
随机推荐
np. Usage and difference of range() and range()
watch VS watchEffect
Electronic bidding procurement mall system: optimize traditional procurement business and speed up enterprise digital upgrading
基于GEC6818开发板的相册
开源版思源怎么私有部署
第3章业务功能开发(添加线索备注,自动刷新添加内容)
SLAM综述阅读笔记七:Visual and Visual-Inertial SLAM: State of the Art, Classification,and Experimental 2021
This points to problems, closures, and recursion
Pure C handwriting thread pool
Unity3D学习笔记10——纹理数组
Chapter 3 business function development (view clue details)
codeforces 1708E - DFS Trees
2022牛客多校二_ E I
为什么会出现Script file ‘D:\Anaconda3\envs\paddle_env\Scripts\pip-script.py‘ is not present.
JS 疫情宅在家,学习不能停,七千字长文助你彻底弄懂原型与原型链
c语言分层理解(c语言数组)
Cultural tourism and data collection | travel to Yunnan in an artistic way
The difference between [x for X in list_a if not np.isnan (x)] and [x if not np.isnan (x) else none for X in list_a]
Document translation__ Salt and pepper image denoising based on adaptive total variation L1 regularization
Flat die cutting machine