Write a program which asks the user for four numbers and then tells them one of the following:
Write a program which asks the user for four numbers and then tells them one of the following:
· That there were more even numbers than odd numbers
· That there were more odd numbers than even numbers
· That there were the same number of even and odd numbers
英語人氣:973 ℃時(shí)間:2020-05-12 03:43:18
優(yōu)質(zhì)解答
#include
void main(void)
{
int n,number[4],even,odd;
even=odd=0;
printf("please input 4 interger numbers:\n");
for(n=0;n能排下版嗎? 謝謝VC6標(biāo)準(zhǔn)代碼模式,你可以自行調(diào)整,如需要解釋我等下重新加上注釋我用的是python2.7. 直接復(fù)制好像不行。。那我再發(fā)一下代碼,增加了注釋,自己看看能否用。可能平臺(tái)不同,程序有所不同,具體python2.7怎么用我也不清楚。你這個(gè)發(fā)到C/C++了。#include void main(void)//vc6平臺(tái)通過,其他平臺(tái)可能為main()即可{ int n,number[4],even,odd; even=odd=0; printf("please input 4 interger numbers:\n");//提示請輸入4個(gè)整數(shù) for(n=0;n<=3;n++) {scanf("%d",&number[n]);//請輸入4個(gè)整數(shù) } for(n=0;n<=3;n++) {if(number[n]%2==0) even++;//統(tǒng)計(jì)偶數(shù)數(shù)目else if(number[n]%2==1) odd++;//統(tǒng)計(jì)奇數(shù)數(shù)目 } if(even==odd)//如果奇數(shù)偶數(shù)相等printf("That there were the same number of even and odd numbers\n"); else if (even>odd)//如果偶數(shù)多于奇數(shù)printf("That there were more even numbers than odd numbers\n"); else if(even
我來回答
類似推薦
- Write a program which asks the user for four numbers(Python)
- 英語翻譯
- COmqarethe countryside and the city.And then write a passage about them.the following words ma...
- Write a program which allows the user to enter a list of numbers.
- The following groups of numbers tell us something Think hard and write it out in English什么意思啊?奇怪的題
- 形容獨(dú)自一人的成語
- 3²和a²是同類項(xiàng)嗎?
- 如圖,國旗上的五角星的五個(gè)角的度數(shù)是相同的,每一個(gè)角的度數(shù)都是( ?。?A.30° B.35° C.36° D.42°
- 三角形數(shù)陣,1;2,3;4,6,5;8,12,10,7;16,24,20,14,9;32,48,40,28,18,11;···
- 直角三角形ABC周長為2,求面積最大值(用三角函數(shù)知識(shí)和建模思想解題)
- 小紅用150 N的力豎直向上提一個(gè)質(zhì)量為10kg的水桶受到的合力是( )N(g取10N/kg)
- 1.125/0.09脫式計(jì)算