⑴ c語言 判斷輸入的乘法等式符合幾進制,並輸出最小符合的進制
這個用窮舉法比較簡單,
i從2一直循環到16
設三個數為opt1,opt2和res
把opt1從i進制變成10進制(提取各位,按權展開)存儲到temp1
把opt2從i進制變成10進制(提取各位,按權展開)存儲到temp2
把res從i進制變成10進制(提取各位,按權展開),存儲到temp3
看temp1*temp2是否等於temp3,如果相等,輸出i結束循環。
⑵ C語言從鍵盤出入兩個整數,求其和。輸出時要求輸出一個完整的等式
C語言從鍵盤出入兩個整數,求其和,可以參考下面的代碼:
#include<stdio.h>
int main()
{
int a1, a2;
printf("請輸入兩個整數:");//輸入以空格間隔 回車結束
scanf_s("%d %d", &a1, &a2);
printf("%d+%d=%d ", a1, a2, a1 + a2);
return 0;
}
(2)C語言輸入等式擴展閱讀:
scanf()是C語言中的一個輸入函數,與printf函數一樣,都被聲明在頭文件stdio.h里,在使用scanf函數時要加上#include <stdio.h>。
函數的第一個參數是格式字元串,它指定了輸入的格式,並按照格式說明符解析輸入對應位置的信息並存儲於可變參數列表中對應的指針所指位置。
⑶ 用C語言輸入一些數學公式
你的x1,x2,y1,y2, t1, t2必須要是函數參數才能算啊,都弄成double
然後函數里把V返回,我給你改好了
double ConerVelocity(int A, double x1, double y1, double x2, double y2, double t1, double t2)
{
double T,V;
T=acos(abs(x1 * x2 + y1 * y2)/ sqrt(x1 * x1 +y1 * y1)/sqrt(x2 * x2 +y2 * y2));
V= (A * (t2-t1))/(2*sin(T/2));
return V;
}
⑷ c語言編程 加等式
#include<stdio.h>
main()
{
int x[1000], i, n, a, b, c, m=0;
scanf("%d", &n);
for (i = 0; i < n; i++)
{
scanf("%d", &x[i]);
}
for (a = 0; a < n; a++)
{
for (b = a+1; b < n; b++)
{
for (c = b+1; c < n; c++)
{
if (a != b != c&&x[a] + x[b] == x[c])
{
m++;
}
}
}
}
printf("%d", m);
}
⑸ 用c語言計算等式
#include
main()
{
int a,b,c;
for(a=0;a<9;a++)
for(b=0;b<9;b++)
for(c=0;c<9;c++)
{
if((100*a+10*b+c + 100*c+10*b+a) == 1333)
printf("a:%d,b:%d,c:%d\n",a,b,c);
}
}
原理就是窮舉,不過要注意的是100*a+10*b+c這種表示方式代表的是a百b十c,在很多地方都有用。程序我剛試過了~肯定沒問題,一共有4組答案,樓長看我上班呢還給你寫程序給個最佳答案吧~
⑹ 用C語言編程:輸入命題公式的合式公式,求出公式的真值表,並輸出該公式的主合取範式和主析取範式
A-Z + is OR * is AND _ is → # is⊕(圓圈裡加個+) @ is ⊙
$ is ↑ 命題的"與非" 運算( "與非門" )
% is ↓ 命題的"或非"運算( "或非門" )
Input the source formula:
A*!S+R
NORMALc: (!A*!B*!R)+(A*!B*!R)+(!A*B*!R)+(A*B*!R)+(!A*!B*R)+(!A*B*R)+(A*B*R)
NORMALd (!A+B+!R)
Error!
Input the source formula:
A#B
Here!
4countTerms
NORMALc: (A*!B)+(!A*B)
NORMALd (A+B)*(!A+!B)
Error!
Input the source formula:
stack<char> stk;
bool isVar(char ch)const;
void addMin(int minterm);
void addMax(int maxterm);
bool compute(int minterm);
void getInversePoland();
int countTerms(int n);
void assign(int minterm);
stack<bool> boolStk;
public:
formulaBase();
formulaBase(const formulaBase& rhs);
~formulaBase();
void getSource();
cout<<"Invalid input !"
"Operate again:"<<endl;
cin>>sourceFormula;*/
}
void formulaBase::getInversePoland()
{
char temp,temp1;
for(int i=0;sourceFormula[i]!='