奇数,偶数使用 [英] Odd , even numbers use

查看:149
本文介绍了奇数,偶数使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是C编程的初学者,我只是想知道为什么我们编写检测奇数或偶数的程序以及它的用途,如果可能的话给出例子,谢谢!



我尝试了什么:



Hi , I'm beginner in C programming , i just want to know why do we code programmes that detect odd or even numbers and what is the use of that , give examples if possible , thanks !

What I have tried:

#include<stdio.h>
#include<stdlib.h>

main()
{
	int N,i,sum,odd,even;
	system("color a ");
	printf("give a number : ");
	scanf("%d",&N);
	sum=0;
	even=0;
	odd=0;
	for(i=0;i<=N;i++)
	{
		if(i%3!=0&&i%4!=0)
		{
		sum=sum+i;
		if(i%2==0)
		even+=i;
		else
		odd+=i;
		}
	}
	printf("sum odd = %d \n sum even = %d \n sum all = %d",odd,even,sum);
	
	return 0;
}

推荐答案

大量的东西!

在英国,奇数房子往往是在街道的一边,甚至在另一边。

16位值通常必须存储在以偶数开头的地址上(这称为字对齐) - 如果你使用指针它解决了一个可以给出问题的奇数。

如果一个整数是奇数,它不能除以2 - 或者如果你这样做,你不能将它乘以2得到相同的你开始使用的数字。



有无数的例子说明为什么你可能想知道是奇怪还是偶数,但我们不是来做你的功课!
Loads of things!
In the UK, odd number houses are often on one side of the street, even ones on the other.
16 bit values often have to to be stored on addresses starting with an even number (this is called word alignment) - if you use a pointer that addresses an odd number it can give problems.
If an integer is odd, it can't be divided by two - or if you do, you can't multiply it by two and get the same number you started with.

There are countless examples of why you might want to know is something is odd or even, but we aren't here to do your homework!


只有一个例子。



成像例如化学过程:

a。)机器有一个输入端口A和一个中间点I。

b。)为了处理材料,它将被移动从A到I并返回。

c。)您只能在输入端口A上装载/卸载机器



请求:材料需要以一定的速度处理一段时间T,速度为V

问题:材料在端口A到底的最终没有的顶点是什么卸载它。 偶数在这里



Real(但很可能是抽象)示例: Jigger染色机| Jigger染色机的染色工艺|跳汰机染色机的优点|跳汰机染色机的缺点 - 纺织学习者 [ ^ ]
Only one example more.

Imaging a e.g. chemical process:
a.) A machine has an enter port "A" and an intermediate point "I".
b.) To process the material it will be moved from "A" to "I" and back.
c.) You can load/unload the machine only on the enter port "A"

Request : The material needs to be processed for a certain time T at a speed V
Question: What is the optimum no of cicles that at the end the material is on port "A" to unload it. Even counts here

Real (but most probably Abstract) example: Jigger Dyeing Machine | Dyeing Process with Jigger Dyeing Machine | Advantages of Jigger Dyeing Machine | Disadvantages of Jigger Dyeing Machine - Textile Learner[^]


我必须在前几天这样做。我们有一系列激光和相机,可以看到它们的目标。我们使他们的IP地址对应于他们所在目标对象的哪一侧 - 可能性在左侧,甚至在右侧。我根据它们所在的位置确定将数据放在何处,然后从数据流中保存其IP地址的最后一个八位字节的字节中获取数据。



这种事情非常普遍。
I had to do that just the other day. We have a series of LASERs and cameras that looking at where they are aimed. We make their IP addresses correspond to which side of the target object they are on - odds are on the left, even on the right. I determine where to place their data based on which side they are on and I get that from a byte in the data stream that holds the last octet of their IP address.

This kind of thing is really quite common.


这篇关于奇数,偶数使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆