本文目錄一覽:
C語言編程源代碼翻譯
#inc1udestdio.h//包含標準輸入輸出函數庫,包含以後可以調用已經寫好的庫函數
int main(void)//定義程序入口,參數列表為空
{//程序塊開始標誌
int dogs;//定義整形變量,變量名為dogs
printf(“How many dogs do you have?\n”);//對控制台輸出引號內的內容,並換行
scanf(“%d”,dogs);//從控制台輸入數據,並將數據傳給dogs
printf(“so you have %d dog(s)!\n”,dogs);//打印輸出結果,用dogs的內容取代%d
return 0;//程序返回值為0
}//程序塊結束
求將以下的C語言代碼翻譯成python語言!!急!!
price1 = 4.5
price2 = 5.5
price3 = 5.5
thing1 = raw_input(‘please input the first thing you wang to bug\n’)
print thing1
num1 = int(raw_input(‘please input the number you need\n’))
print num1
print ‘the price is %f’ % float(num1*price1)
thing2 = raw_input(‘please input the first thing you wang to bug\n’)
print thing2
num2 = int(raw_input(‘please input the number you need\n’))
print num2
print ‘the price is %f’ % float(num2*price2)
thing3 = raw_input(‘please input the first thing you wang to bug\n’)
print thing3
num3 = int(raw_input(‘please input the number you need\n’))
print num3
print ‘the price is %f’ % float(num3*price3)
print ‘the final price is %f’ % float(num1*price1+num2*price2+num3*price3)
用C語言編寫一個簡單翻譯程序
LZ 的那種方法 可以實現 ,但很顯然是不實用,因為那樣記錄的也太多了吧,,,
我覺得,你可以記錄下常用的特殊短語 像: hello China就可以了,因為很大一部分就是按照順序翻譯的,「有道」也經常出現這種問題的,以下是自己在用參考「有道」的時候的實現的一些想法,可以作為參考:
如果想智能點的話,你就得「教會」這個 【 英語和漢語 】這兩門課 教的方法,就是把你會的東西全都教給他,比如說:
首先,你可以為每個單詞定義一個struct數據結構,裏面包含的是這個單詞的 1. 【字義】(一個單詞總不止一個意思吧)2.【詞性】(你學習語法的時候要用到吧)3.【其他】(詞組了什麼的,有發音功能的話還得記錄音標吧、、呵呵)
然後,要教它語法吧、、、這其實是最難的,語法就相當於你的算法了,程序的靈魂所在;
這也許就是C一直吸引着我們的地方,將抽象變為具體,呵呵、、祝你學習愉快、、、
C語言代碼翻譯
#include stdio.h
#include stdlib.h
#include time.h //三個頭文件
void wait ( int seconds ) //定義一個具有等待功能的函數
{
int a=0;
clock_t endwait; //clock_t 就是long 型
//通過下面兩部實現等待seconds秒的作用
endwait =clock()+seconds*CLK_TCK;
while (clock()endwait){}
}
void main()
{
int t,m,s;
printf(“input counterdown time in seconds\n”);
scanf(“%d”,t);
printf(“\n===================\n”);
while(1) //只要時間不為0 不斷執行循環
{
wait (1); //執行wait函數 程序等待一秒
t–; //倒計時總秒數每隔一秒自動減一
if(t==0)
break;
s = t % 60; //確定倒計時分鐘
m = t / 60; //確定倒計時秒數
printf(“\r\t%02d:%02d”,m,s);
}
exit(0);
}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/238332.html