学习敲代第二天
Posted yuzhenghan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了学习敲代第二天相关的知识,希望对你有一定的参考价值。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>//将三个数按从大到小输出
#include<stdio.h>//将三个数按从大到小输出
int main(){
int a, b, c, num;
printf("输入三个整数 ");
scanf("%d%d%d", &a, &b, &c);
if (a > b){
num = a;
a = b;
b = num;
}
if (a < c){
num = c;
c = a;
a = num;
}
if (b < c){
num = c;
c = a;
b = num;
}
printf("从大到小顺序:%d %d %d ", a, b, c);
system("pause");
return 0;
}
int a, b, c, num;
printf("输入三个整数 ");
scanf("%d%d%d", &a, &b, &c);
if (a > b){
num = a;
a = b;
b = num;
}
if (a < c){
num = c;
c = a;
a = num;
}
if (b < c){
num = c;
c = a;
b = num;
}
printf("从大到小顺序:%d %d %d ", a, b, c);
system("pause");
return 0;
}
#include<stdio.h>//求十个整数中最大的值
#include<stdlib.h>
int main(){
int arr[10] = { 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int max = arr[0];
int i = 0;
for (i = 0; i < 10; i++){
if (max>arr[i]){
continue;
}
else{
max = arr[i];
}
}
printf("max=%d ", max);
system("pause");
return 0;
#include<stdlib.h>
int main(){
int arr[10] = { 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int max = arr[0];
int i = 0;
for (i = 0; i < 10; i++){
if (max>arr[i]){
continue;
}
else{
max = arr[i];
}
}
printf("max=%d ", max);
system("pause");
return 0;
}
//给的两个整形变量的值,将两个值的内容进行交换。
#include <stdio.h>
void main(){
int a = 1;
int b = 2;
printf("a=%d ", b);
printf("b=%d ", a);
system("pause");
return 0;
}
#include <stdio.h>
void main(){
int a = 1;
int b = 2;
printf("a=%d ", b);
printf("b=%d ", a);
system("pause");
return 0;
}
#include<stdio.h>//求两个数之间是的最大公约
int hcf(int x, int y){
int t;
if (x < y){
t = x;
x = y;
y = t;
}
while ((t = x%y) != 0){
x = y;
y = t;
}
return y;
}
int lcf(int x, int y, int m)
{
return x*y / m;
}
int main() {
int hcf(int, int);
int lcf(int, int, int);
int x, y, h, l;
printf("请输入两个数 ");
scanf("%d%d", &x, &y);
h = hcf(x, y);
l = lcf(x, y, h);
printf("最大公约数:h=%d 最小公倍数为:l=%d ",h, l);
return 0;
}
int hcf(int x, int y){
int t;
if (x < y){
t = x;
x = y;
y = t;
}
while ((t = x%y) != 0){
x = y;
y = t;
}
return y;
}
int lcf(int x, int y, int m)
{
return x*y / m;
}
int main() {
int hcf(int, int);
int lcf(int, int, int);
int x, y, h, l;
printf("请输入两个数 ");
scanf("%d%d", &x, &y);
h = hcf(x, y);
l = lcf(x, y, h);
printf("最大公约数:h=%d 最小公倍数为:l=%d ",h, l);
return 0;
}
以上是关于学习敲代第二天的主要内容,如果未能解决你的问题,请参考以下文章