C编程
我在做一道题:
编写一个程序读入一个5位数,羡慕判断该整数是否是回文。
(回文指顺读和倒读都一样的数字和文字语句,例:12321,55555)
提示:使用除法运算符和求模运算符把该数分解成单位个数。
程序清单:
我写的是:
#include<stdio.h>
void main()
{
long int x;
int i=0,j,y,number[5]={0};
scanf("%ld",x);
for(y=10000;y>=1;y=y/10)
{
number[i]=x/y;
x=x%y;
i++;
printf("%d",number[i]);
}
i=i-1;
for(i=j;j>=1;j--)
{
printf("%-2d",number[j]);
}
getch();
}
去编译又没有错误,但不是我想要的结果,
各位高手帮帮忙 急急!!!
scanf("%ld",x); ——> scanf("%ld",&x);
楼上正解......
#include<stdio.h>
void main()
{
long x;
int i=0,j,y,number[5];//number[5]={0};没什么用
scanf("%ld",&x);//应该是&x
for(y=10000;y>=1;y=y/10)
{
number[i]=x/y;
x=x%y;
i++;
printf("%d",number[i-1]);//i已经自加过了,要减一
}
i=i-1;
for(j=i;j>=0;j--)//j=i
{
printf("%-2d",number[j]);
}
}
C/C++ code
相关问答:
写了个测试程序如下
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
分别用结构化方法和面向对象方法编程实现下面要求:
对Circle和Rectangle实现以下功能Center,Move,Rotate,Print.
自己先订以下,这是一个刚学习计算机的人问我的
学习,看看
继续顶哦
学习了。
go o ......
帮帮忙,谢谢~
1. Write a program to perform a topological sort on a graph.
2. Write a program to solve the single‐source shortest‐path problem (Dijkstra
algorithm).
3. Write a program ......
目前公司在做其他公司的C/S软件的代理,现在想仿照他的产品自己做,只是功能仿照而已,不清楚他们是用什么技术开发的,我们用winform开发了相似的功能,他们的源代码我们没有,因此在源代码上没有仿照的可能性,我们 ......
谁能帮我把下面这些代码改成VB形式的,多谢了,急用~~
#include "stdlib.h"
#include "math.h"
#include "stdio.h"
float objfx(float x[]);
void constraint(float x[],float g ......