如何编写程序以获得下一个奇数内存(限制400个字节) [英] how to write a program to get next odd number memory (limit 400 bytes)

查看:62
本文介绍了如何编写程序以获得下一个奇数内存(限制400个字节)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这段代码,但它超过400字节


#include< stdio.h>

int main()

{

int x [4],i;

for(i = 0; i< 4; i ++)

{

scanf("%d",& x [i]); //从用户那里获取所有号码

}

for( i = 0; i< 4; i ++)

{

if(x [i]%2 == 0)//得到下一个奇数

x [i] ++;

}

for(i = 0; i< 4; i ++)

{

printf("%d \ n",x [i]); //打印奇数

}

返回0;

}

i tried this code but it is more than 400 bytes

#include<stdio.h>
int main()
{
int x[4],i;
for(i=0;i<4;i++)
{
scanf("%d",&x[i]);//to get all numbers from user
}
for(i=0;i<4;i++)
{
if(x[i]%2==0)//to get the next odd number
x[i]++;
}
for(i=0;i<4;i++)
{
printf("%d\n",x[i]);//to print odd numbers
}
return 0;
}

推荐答案

即使有评论也是280字节。
It''s 280 bytes even with comments.


如果是内存限制(100字节)我该如何解决这个问题???

请帮助我!!!
and if the memory limit (100 bytes) how can i solve this problem???
please help me!!!

你能描述的问题比更详细吗?得到下一个奇数记忆 ?至少应该输入什么用户以及应该输出什么。
Can you describe the problem somewhat more detailed than "get next odd number memory" ? At least what user is expected to enter and what is supposed to be output.


这篇关于如何编写程序以获得下一个奇数内存(限制400个字节)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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