才学了2天C语言就遇见难题,各位帮帮忙

来源:百度知道 编辑:UC知道 时间:2024/05/06 16:19:44
作业:
编写一个程序。要求输入一个数,输出该数分别与1——10的数相乘的结果。输入格式如图:(图我就打在这里吧。各位帮帮忙)
_____________________________
请输入一个数字:5

5*1=5 5*2=10
5*3=15 5*4=20
5*5=25 5*6=30
5*7=35 5*8=40
5*9=45 5*10=50
Press any key to continue

__________________________________

我自己做的
#include<stdio.h>

void main()
{
int a,b,c;
scanf("%d",&a);
{
for (b=1,b<=5;b++)

c=a*(2b-1);
printf("%d*%d=%d\t",a,b,c);

c=a*2*b;
print("%d*%d*%d\n",a,b,c);
}
}
听人家说要用循环函数。for开头的。。但不知道循环函数怎么用。

#include<stdio.h>
main()
{ int a,b,c,i;
scanf("%d",&a);
{ for(i=1;i<=5;i++)
{b=2*i-1;
c=a*b;
printf("%d*%d=%d\t",a,b,c);
b=2*i;
c=a*b;
printf("%d*%d=%d\n",a,b,c);
}
}
}
这是根据你的思路编写的。要注意变量值的变化,你编的程序b值在每次循环中没有改变得不到想要的结果,这个错误很常见。另外,你编的程序for循环中少了{ },无法完成循环,符号书写也有错误。

你要学的还多呢,,

这个最简单了,你看下满意不?
#include<stdio.h>
void main()
{
int n;
scanf("%d", &n);
for(int i=1;i<=10;i++)
{
printf("%d*%d=%d\t",n,i,n*i);
if(i%2==0)
{
printf("\n");
}
}

}

#include <stdio.h>

void main()
{
int a, b;
scanf("%d", &a);
getchar();
for (b=0; b<5; b++)
{
printf("%d*%d=%d\t", a, b*2+1, a*(b*2+1));
printf("%d