本文介绍了如何将thispython转换为C.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import csv
def fuzzy(pr,ps,pt,hr,hs,ht):
ya = [0,0,0]
tidak = [0,0,0,0,0,0]
if (pr > 0) and (hr > 0):
tidak[0] = min (pr,hr);
if (ps>0) and (hr >0):
tidak[1] = min (ps,hr);
if (pt>0) and (hr >0):
tidak[2] = min (pt,hr);
if (pr>0) and (hs >0):
ya[0] = min (pr,hs);
if (ps>0) and (hs >0):
tidak[3] = min (ps,hs);
if (pt>0) and (hs >0):
tidak[4] = min (pt,hs);
if (pr>0) and (ht >0):
ya[1] = min (pr,ht);
if (ps>0) and (ht >0):
ya[2] = min (ps,ht);
if (pt>0) and (ht >0):
tidak[5] = min (pt,ht);
return max(ya),max(tidak)
def defuzzy(ya,tidak):
return ((ya * 60) + (tidak *35)) / (ya + tidak)
def tes_kmptn(kompetensi):
pr = 0;
ps = 0;
pt = 0;
if (kompetensi >= 1.5):
pt =1 ;
elif (kompetensi > 1) and (kompetensi <1.5):
ps = (1.5 - kompetensi)/(1.5 - 1);
pt = 1 - ps;
elif (kompetensi > 0.5) and (kompetensi < 1):
pr = (1 - kompetensi) / (1 - 0.5);
ps = 1 - pr;
elif (kompetensi <= 0.5):
pr = 1;
return pr, ps, pt
def kprdn(kepribadian):
hr = 0;
hs = 0;
ht = 0;
if (kepribadian >= 66):
ht = 1;
elif (kepribadian > 44) and (kepribadian < 66):
hs = ( 66 - kepribadian)/(66-44);
ht = 1 - hs;
elif(kepribadian == 44):
hs = 1;
elif (kepribadian > 22) and (kepribadian < 44):
hr = (44-kepribadian)/(44-22);
elif (kepribadian <= 22 ):
hr = 1;
return hr,hs,ht;
with open('book1.csv') as file:
reader = csv.reader(file, delimiter=',')
next(reader)
with open('TebakanTugas3.csv', 'w', newline='') as data:
fiedlname =['ID','kompetensi','Hutang']
writer = csv.DictWriter(data,fiedlname)
writer.writeheader()
for row in reader:
hR,hS,hT = kompetensi(float(row[1]))
pR, pS, pT = Hutang(float(row[2]))
ya, tidak = fuzzy(pR,pS,pT,hR,hS,hT)
x = defuzzy(ya, tidak)
if(x >=60):
print('No', row[0],' penghasian',row[1],' hutang',row[2],' layak mendapatkan BLT')
writer.writerow({'No':row[0],'kompetensi':row[1],'Hutang':row[2]})
我尝试过:
What I have tried:
import csv
def fuzzy(pr,ps,pt,hr,hs,ht):
ya = [0,0,0]
tidak = [0,0,0,0,0,0]
if (pr > 0) and (hr > 0):
tidak[0] = min (pr,hr);
if (ps>0) and (hr >0):
tidak[1] = min (ps,hr);
if (pt>0) and (hr >0):
tidak[2] = min (pt,hr);
if (pr>0) and (hs >0):
ya[0] = min (pr,hs);
if (ps>0) and (hs >0):
tidak[3] = min (ps,hs);
if (pt>0) and (hs >0):
tidak[4] = min (pt,hs);
if (pr>0) and (ht >0):
ya[1] = min (pr,ht);
if (ps>0) and (ht >0):
ya[2] = min (ps,ht);
if (pt>0) and (ht >0):
tidak[5] = min (pt,ht);
return max(ya),max(tidak)
def defuzzy(ya,tidak):
return ((ya * 60) + (tidak *35)) / (ya + tidak)
def tes_kmptn(kompetensi):
pr = 0;
ps = 0;
pt = 0;
if (kompetensi >= 1.5):
pt =1 ;
elif (kompetensi > 1) and (kompetensi <1.5):
ps = (1.5 - kompetensi)/(1.5 - 1);
pt = 1 - ps;
elif (kompetensi > 0.5) and (kompetensi < 1):
pr = (1 - kompetensi) / (1 - 0.5);
ps = 1 - pr;
elif (kompetensi <= 0.5):
pr = 1;
return pr, ps, pt
def kprdn(kepribadian):
hr = 0;
hs = 0;
ht = 0;
if (kepribadian >= 66):
ht = 1;
elif (kepribadian > 44) and (kepribadian < 66):
hs = ( 66 - kepribadian)/(66-44);
ht = 1 - hs;
elif(kepribadian == 44):
hs = 1;
elif (kepribadian > 22) and (kepribadian < 44):
hr = (44-kepribadian)/(44-22);
elif (kepribadian <= 22 ):
hr = 1;
return hr,hs,ht;
with open('book1.csv') as file:
reader = csv.reader(file, delimiter=',')
next(reader)
with open('TebakanTugas3.csv', 'w', newline='') as data:
fiedlname =['ID','kompetensi','Hutang']
writer = csv.DictWriter(data,fiedlname)
writer.writeheader()
for row in reader:
hR,hS,hT = kompetensi(float(row[1]))
pR, pS, pT = Hutang(float(row[2]))
ya, tidak = fuzzy(pR,pS,pT,hR,hS,hT)
x = defuzzy(ya, tidak)
if(x >=60):
print('No', row[0],' penghasian',row[1],' hutang',row[2],' layak mendapatkan BLT')
writer.writerow({'No':row[0],'kompetensi':row[1],'Hutang':row[2]})
推荐答案
int maximum(int a, int b)
{
if( (a > b) && (b < a) )
{
return a;
}
return b;
}
这篇关于如何将thispython转换为C.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!