当前位置:网站首页>C language learning log 10.11
C language learning log 10.11
2022-06-13 04:57:00 【Today is also a day without baldness】
Today is mainly about writing questions
Topic 1 .
Different countries in the world have different habits of writing dates . For example, Americans are used to writing “ month - Japan - year ”, And the Chinese are used to writing “ year - month - Japan ”. Now please write a program , Automatically change the date in American format into the date used by China .
Input format :
Type in a line and press “mm-dd-yyyy” To the moon 、 Japan 、 year . The date given in the title guarantee is 1900 The legal date from New Year's day to the present .
Output format :
In a row, press “yyyy-mm-dd” The format gives the year 、 month 、 Japan .
sample input :
03-15-2017No blank lines at the end
sample output :
2017-03-15No blank lines at the end
#include<stdio.h>
int main(void)
{
int a,b,c,d;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
b=-b;
c=-c;
if(a/10>0&&b/10>0)
{
printf("%d-%d-%d",c,a,b);
}else if(a/10<=0&&b/10>0){
printf("%d-0%d-%d",c,a,b);
}else if(a/10<=0&&b/10<=0){
printf("%d-0%d-0%d",c,a,b);
}else if(a/10>0&&b/10<=0){
printf("%d-%d-0%d",c,a,b);
}
}Topic two .
Know a student's math 、 The grades of English and computer courses are 87 branch 、72 Points and 93 branch , Beg the student 3 The GPA of the course ( The result is output as an integer ).
Input format :
No input for this question
No blank lines at the end
Output format :
Output the results in the following format :
math = 87, eng = 72, comp = 93, average = Calculated GPA No blank lines at the end
#include<stdio.h>
int main(void)
{
const int math=87;
const int eng=72;
const int comp=93;
int average;
average=(math+eng+comp)/3;
printf("math = %d, eng = %d, comp = %d, average = %d",math,eng,comp,average);
}Question three .
For the two integers entered , Output the sum difference product quotient as required .
Input format :
Enter two numbers in one line that do not exceed 100 Non-negative integer a and b, The middle is separated by a space , And guarantee b Not for 0.
Output format :
There are four lines in total , The format is :
[a] + [b] = [a+b]
[a] - [b] = [a-b]
[a] * [b] = [a*b]
[a] / [b] = [a/b] among , Bracketed content ( Such as [a]、[b]、[a+b] etc. ) Represents the value of the corresponding integer or operation result , When outputting, use the actual value instead of .
also : If a It can be b to be divisible by , that a/b The output should be in integer format , otherwise a/b The output is in a format with two decimal places .
Tips : Notice the spaces in the expression .
sample input 1:
6 3No blank lines at the end
sample output 1:
6 + 3 = 9
6 - 3 = 3
6 * 3 = 18
6 / 3 = 2No blank lines at the end
sample input 2:
8 6sample output 2:
8 + 6 = 14
8 - 6 = 2
8 * 6 = 48
8 / 6 = 1.33#include<stdio.h>
int main(void){
int a,b,c,d,e;
double f;
scanf("%d %d",&a,&b);
c=a+b;
d=a-b;
e=a*b;
if((0<=a&&a<=100)&&(0<b&&b<=100)){
printf("%d + %d = %d\n",a,b,c);
printf("%d - %d = %d\n",a,b,d);
printf("%d * %d = %d\n",a,b,e);
}
if(a%b==0){
printf("%d / %d = %d\n",a,b,(int)a/b);
}else{
f=a/(b*1.0);
printf("%d / %d = %.2f\n",a,b,f);
}
}
边栏推荐
- Promise processing JS multithreads get the same processing result after all the results are obtained
- Sub paragraph of Chapter 16
- Advanced C - Section 3 - character functions and string functions
- [leetcode]- sliding window
- Implementing the driver registration initcall mechanism on stm32
- Collection of some compatibility issues
- Little C's Notepad
- Use go to add massive data to MySQL
- C#获取WebService接口的所有可调用方法[WebMethod]
- Clause 28: understanding reference folding
猜你喜欢

Reductive elimination

Kaggle 时间序列教程

Design system based on MVC using javeswingjdbc

QT interface rendering style

Analysis of scoped attribute principle and depth action selector

Simple-SR:Best-Buddy GANs for Highly Detailed Image Super-Resolution论文浅析
![[LeetCode]-二分查找](/img/7f/7d1f616c491c6fb0be93f591da6df1.png)
[LeetCode]-二分查找

Logical point

Spice story

Regular expressions in QT
随机推荐
Section 3 - functions
Go/golang connection to database
Normal distribution (Gaussian distribution)
[leetcode]- binary search
UNO
Kaggle 时间序列教程
Clause 30: be familiar with the failure of perfect forwarding
QT brushes and brushes
[JS solution] leedcode 200 Number of islands
Implementing the driver registration initcall mechanism on stm32
2021TPAMI/图像处理:Exploiting Deep Generative Prior for Versatile Image Restoration and Manipulation
Flutter dart variables and constants
All blog navigation
How to lay copper in AD (aluminum designer)
Chapter 13 abstraction: address space
E - Lucky Numbers
Clause 28: understanding reference folding
Keil uses j-link to burn the code, and an error occurs: Flash download failed - one of the "Cortex-M3" solutions
Brick story
CMB's written test -- data analysis