تبلیغات
دانلود سورس پروژه های مختلف برنامه نویسی، آموزش برنامه نویسی - سورس الگوریتم کوله پشتی در C++
دانلود سورس پروژه های مختلف برنامه نویسی، آموزش برنامه نویسی
دانلود رایگان سورس پروژه
سایت برنامه نویسی تک کدر takcoder.ir


آموزش برنامه نویسی با استفاده از نوین ترین روش و ارائه پروژه های نمونه و مجموعه عظیم سورس کدهای آماده برای شما دوستان

مدیر سایت : Yahya Taherzadeh
نویسندگان
نظرسنجی
زبان برنامه نویسی مورد علاقه شما؟






اینم سورس برنامه ی معروف کوله پشتی به زبان توربو C++ که میدونم خیلی از دوستان خیلی دنبالش میگردند چون واسه درس طراحی الگوریتم، الگوریتم پایه ای هست.
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
void sortbypw(int p[],int w[],int n)
{
 int i,t,j;
 for (i=0;i<=n-1;i++)
  for (j=i+1;j<=n;j++)
     if(((float)p[i]/w[i])<((float)p[j]/w[j]))
         {
     t=p[i];
     p[i]=p[j];
     p[j]=t;
     t=w[i];
     w[i]=w[j];
     w[j]=t;
    }
}

float knapsack(int p[],int w[],int n,int m)
{
sortbypw(p,w,n);
int w1=m;
int i=0;
float pp=0;
while (i<=n && w1>0)
 {
    if (w[i]<w1)
    {
     cout<<" p : "<<p[i];
     w1-=w[i];
     pp+=p[i];
     i++;
    }
    else
    {
     cout<<" p : "<<p[i];
     pp+=w1*((float)p[i]/w[i]);
    w1=0;
    }
 }
 return pp;
}

void main()
{
 int p[100]={6,12,7,18,9,30};
 int w[100]={1,5,3,9,5,20};
 clrscr();
 cout<<"If You Want Input Data Press (Y) Else Press (N) :";
 char ch=getche();
 if (ch=='n')
      cout<<"\n\n Arzesh Knapsack : "<<knapsack(p,w,5,20);
 else
     {
     int n,m;
     cout<<"\nEnter Weight Knapsack : ";
     cin>>m;
     cout<<"Enter Num : ";
     cin>>n;
     for (int i=0;i<n;i++)
     {
      cout<<"Enter Arzesh : ";
      cin>>p[i];
      cout<<"\nEnter Weight : ";
      cin>>w[i];
      gotoxy(20,wherey()-2);
      cout<<" P/W Is : "<<(float)p[i]/w[i];
      gotoxy(1,wherey()+2);
      cout<<".......................................\n";
     }
      cout<<"\n\n Arzesh Knapsack : "<<knapsack(p,w,n-1,m);
     }
 getch();
}





نوع مطلب : آموزش، پروژه های رایگان، سی| سی پلاس پلاس، پروژه های تکمیل شده، ساختمان داده، طراحی الگوریتم، 
برچسب ها : کد کوله پشتی، الگوریتم کوله پشتی، کوله پشتی C++، کوله پشتی سی پلاس پلاس، الگوریتم های طراحی الگوریتم، الگوریتم کوله پشتی در سی پلاس،
لینک های مرتبط :
Yahya Taherzadeh
سه شنبه 19 آذر 1392
شنبه 18 شهریور 1396 08:28 ق.ظ
I know this if off topic but I'm looking into starting my own blog and was wondering what
all is needed to get setup? I'm assuming having a blog like
yours would cost a pretty penny? I'm not very web smart so I'm not 100% sure.
Any recommendations or advice would be greatly appreciated.
Kudos
یکشنبه 25 تیر 1396 10:42 ق.ظ
When someone writes an article he/she maintains the thought of a user in his/her mind that how a user can be aware of it.
Therefore that's why this paragraph is great.
Thanks!
یکشنبه 25 تیر 1396 06:20 ق.ظ
Hmm it appears like your website ate my first comment (it was extremely long)
so I guess I'll just sum it up what I submitted and say, I'm thoroughly enjoying your blog.
I as well am an aspiring blog writer but I'm still new to the whole thing.
Do you have any tips for beginner blog writers? I'd certainly appreciate it.
شنبه 24 تیر 1396 09:07 ب.ظ
Howdy! This blog post couldn't be written much better!
Looking at this article reminds me of my previous roommate!
He continually kept talking about this. I will send this post to him.
Fairly certain he will have a good read. Thanks for sharing!
یکشنبه 18 تیر 1396 06:06 ب.ظ
Ridiculous quest there. What occurred after? Good luck!
دوشنبه 12 تیر 1396 11:11 ب.ظ
Precisely what I was looking for, thank you for putting up.
دوشنبه 12 تیر 1396 09:07 ق.ظ
Thanks for finally talking about >دانلود سورس پروژه های مختلف برنامه نویسی، آموزش
برنامه نویسی - سورس الگوریتم کوله پشتی در C++ <Liked it!
چهارشنبه 31 خرداد 1396 07:37 ب.ظ
You could definitely see your skills within the work you
write. The sector hopes for even more passionate writers such
as you who are not afraid to say how they believe.
At all times go after your heart.
جمعه 12 خرداد 1396 01:54 ب.ظ
What's up mates, its great post concerning cultureand entirely explained, keep it up all the time.
سه شنبه 2 خرداد 1396 11:05 ب.ظ
I have been browsing online more than 3 hours these days, yet I by no means found any interesting article like
yours. It's lovely value enough for me. Personally, if all webmasters and bloggers made
good content as you probably did, the internet will probably be much more useful than ever before.
جمعه 29 اردیبهشت 1396 01:40 ق.ظ
I'm impressed, I have to admit. Rarely do I come across a blog that's both equally educative and engaging, and without a
doubt, you've hit the nail on the head. The problem is something not enough men and
women are speaking intelligently about. I'm very happy I came across this
during my search for something concerning this.
پنجشنبه 14 اردیبهشت 1396 12:36 ق.ظ
Normally I don't read article on blogs, however I would
like to say that this write-up very pressured me to try and do so!
Your writing taste has been amazed me. Thank you, very nice article.
شنبه 9 اردیبهشت 1396 03:42 ب.ظ
You can definitely see your expertise in the paintings you write.
The sector hopes for more passionate writers like you who
aren't afraid to mention how they believe. Always go after
your heart.
جمعه 25 فروردین 1396 07:38 ب.ظ
An interesting discussion is worth comment.
I believe that you ought to write more on this issue,
it might not be a taboo subject but typically people don't speak about such subjects.
To the next! Many thanks!!
یکشنبه 20 فروردین 1396 12:09 ب.ظ
I go to see every day some blogs and blogs to
read content, except this weblog offers feature based content.
 
لبخندناراحتچشمک
نیشخندبغلسوال
قلبخجالتزبان
ماچتعجبعصبانی
عینکشیطانگریه
خندهقهقههخداحافظ
سبزقهرهورا
دستگلتفکر




صفحات جانبی
آمار وبلاگ
تاییدیه پرداخت
تبلیغات
به سایت تک کدر خوش آمدید