[求助]一个赋值的问题
int main()
{
int n, a=20;
printf("Input a number:");
scanf("%d",&n);
printf("%d",n);
}
如果输入的n的值是97,那怎样才可以把n=97转化为a,并且使最后输出的n的值为a的值20?
#include<stdio.h>
#include<stype.h>
int main()
{
int m, n, x, y, z, sum=0;
int a=31, b=28, c=31, d=30, e=31, f=30;
int g=31, h=31, i=30, j=31, k=30, l=31;
printf("Input date:");
printf("Month:");
scanf("%d",&m);
printf("date:");
scanf("%d",&n);
x=m+96; 就是这里把x换为a到l中的一个,然后用上面定义的值,但我的这种是错的!
sum=x+n;
printf("%d\n",sum);
}
[此贴子已经被作者于2006-11-7 19:40:29编辑过]
#include<stdio.h>
#include<stype.h>
int main()
{
int m, n, x, y, z, sum=0;
int a=31, b=28, c=31, d=30, e=31, f=30;
int g=31, h=31, i=30, j=31, k=30, l=31;
printf("Input date:");
printf("Month:");
scanf("%d",&m);
printf("date:");
scanf("%d",&n);
x=m+96; 如果输入m=1,那么x=97,那么能否把x就转化为a,并且赋予a在上面所定义的值,使x=31?
sum=x+n;
printf("%d\n",sum);
}