سلامنقل قول:
مطالعه و گذشت زمان
Printable View
سلامنقل قول:
مطالعه و گذشت زمان
اگر زبانتون خوبه این کتاب رو حتما بخونید ، نه فقط تابع رو به طرز فوق العاده و ساده ای توضیح داده ، بلکه کلا کتاب منظم و خیلی خوب و ساده نوشته شده.نقل قول:
Jumping into C++
Alex Allain
دوستان این برنامه رو نوشتم اما کامپایل نمیشه ، visual studio هم هیچ ارروری نمیده. ممنون میشم راهنمایی کنید. خودم فک میکنم گیرش سره این تابع product_delete() باشه.
کد:#include "stdafx.h"#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
struct Storage
{
char Good_Name[50];
char Good_ID[20];
long int Available_in_Storage;
char Good_Category[20];
struct Storage *fl;
}*start, *cur, *p;
void insert()
{
char Product_ID[10];
int sw = 0;
long int n;
cout << "Enter Product ID " << endl;
gets_s(Product_ID);
for (p = start; p != NULL&&!sw; p = p->fl)
{
if (strcmp(Product_ID, p->Good_ID))
{
sw = 1;
cout << "Enter the Number of Products to be inserted " << endl;
cin >> n;
p->Available_in_Storage = p->Available_in_Storage + n;
}
if (!sw)
{
p = new struct Storage;
p->fl = NULL;
cur->fl = p;
cur = p;
cout << "Enter the Name of the Products to be Inserted " << endl;
gets_s(p->Good_Name);
strcpy(p->Good_ID, Product_ID);
{
cout << "Enter the category of the specified Product " << endl;
gets_s(p->Good_Category);
cout << "Enter the Number of Available Products in the Sotrage " << endl;
cin >> p->Available_in_Storage;
}
}
}
}
void product_delete()
{
struct Storage *q, *r;
char Product_ID[10];
int sw = 0;
long int n;
cout << "Enter Product ID " << endl;
gets_s(Product_ID);
for (p = start->fl; p != NULL&&!sw; p->fl = p)
{
if (strcmp(Product_ID, p->Good_ID))
{
sw = 1;
cout << "Enter Number of Products you wish to be deleted " << endl;
cin >> n;
if (p->Available_in_Storage < n)
{
cout << "Not enough Product in Storage so it couldn't deleted " << endl;
}
else if (p->Available_in_Storage>n)
{
cout << "Numer of deleted Products = " << (p->Available_in_Storage = p->Available_in_Storage - n) << endl;
}
else
{
p->fl = r;
for (q = start; q->fl != p; q->fl = q)
{
q->fl = r;
p->fl = NULL;
cout << "This product has been deleted and the number is zero " << endl;
}
}
}
}
}
void report()
{
cout << "The list of all products " << endl;
for (start->fl = p; p != NULL; p->fl = p)
{
cout << "Product ID = " << p->Good_ID << endl;
cout << "Product Name : " << p->Good_Name << endl;
cout << "Availability = " << p->Available_in_Storage << endl;
cout << "Product Category : " << p->Good_Category << endl;
}
}
void Search_by_Product_ID()
{
char Product_ID[10];
int sw = 0;
cout << "Enter Product ID so that the search begins " << endl;
gets_s(Product_ID);
for (start->fl = p; p != NULL && !sw; p = p->fl)
{
if (!strcmp(Product_ID, p->Good_ID))
{
sw = 1;
cout << "Product ID = " << p->Good_ID << " = " << Product_ID << endl;
cout << "Product Name : " << p->Good_Name << endl;
cout << "Availability = " << p->Available_in_Storage << endl;
cout << "Product Category : " << p->Good_Category << endl;
}
if (!sw)
{
cout << "ERROR 404 - NOT FOUND " << endl;
}
}
}
void Search_by_Category()
{
char category[20];
int sw = 0;
cout << "Enter Product's Category " << endl;
gets_s(category);
for (start->fl = p; p != NULL && !sw; p = p->fl)
{
if (!strcmp(category, p->Good_Category))
{
sw = 1;
cout << "Product ID = " << p->Good_ID << endl;
cout << "Product Name : " << p->Good_Name << endl;
cout << "Availability = " << p->Available_in_Storage << endl;
//cout << "Product Category : " << p->Good_Category << endl;
}
if (!sw)
{
cout << "ERROR 404 - NOT FOUND " << endl;
}
}
}
void main()
{
char ch;
start = new struct Storage;
start->fl = NULL;
cur = start;
do
{
cout << "Enter I/i for Insert " << endl;
cout << "Enter D/d for Delete " << endl;
cout << "Enter P/p for Search by Product ID " << endl;
cout << "Enter C/c for Search by Category " << endl;
cout << "Enter X/x for Terminating the Program " << endl;
cin >> ch;
switch (ch)
{
case 'I':
case 'i':
insert();
break;
case 'D':
case 'd':
product_delete();
break;
case 'P':
case 'p':
Search_by_Product_ID();
break;
case 'C':
case 'c':
Search_by_Category();
break;
}
} while (ch != 'X' && ch != 'x');
}
سلام. برنامتون مشکلی نداره.فقط باید
#include "stdafx.h"
پاک کنی تا کامپایل شه.من برنامه رو کپی کردم اصلا stdafx رو نمیتونه باز کنه.پاکش کردم کامپایل و اجرا شد.
من با ویژوال استودیو کامپایل میکنم ، اون برای همه ی برنامه هایی که تو ویژوال استودیو نوشته میشن ، باید باشه.نقل قول:
اگه شما کوتیشن ( " " ) رو در باز کردن یک اینکلود استفاده کنین فقط میتونین هدر هایی که خودتون ساختینو باز کنین.برای باز کردن هدر های خود کامپایلر باید از <headername> استفاده کنید که من هرچی دنبال این فایل گشتم پیدا نکردم.(به احتمال زیاد در این نسخه vs حذف شده و توابع مربوطش به هدر های دیگه انتقال یافته.)
سلام
لطفا در این برنامه کمکم کنید
یک فایل ایجاد کنیدکه محتویات آن شامل کلمه ،حروف واعداد باشند و محتویات فایل راخوانده ومجموع هر کدام را محاسبه کندودر یک فایل دیگر نمایش دهد.
قسمت ایجاد وخواندن فایل رو می دونم ولی از مجموع و... بلد نیستم انجامش بدم لطفا کمک کنید.
سلام دوستان کسی هست که بتونه کمک کنه؟
تابعی بازگشتی بنویسید که با دریافت یک ارایه از اعداد صحیح متمایز و یک عدد که ان را کلید می نامیم . کلید را در ارایه جستجو کنددر صورت یافت شدن اندیس خانه ی مربوط و در صورت یافت نشدن مقدار ۱- را بازگرداند
نقل قول:
تابعی بازگشتی بنویسید که با دریافت یک ارایه از اعداد صحیح متمایز و یک عدد که ان را کلید می نامیم . کلید را در ارایه جستجو کنددر صورت یافت شدن اندیس خانه ی مربوط و در صورت یافت نشدن مقدار ۱- را بازگرداند
کد:#include<iostream>
#include<conio.h>
using namespace std;
void finding(int ara[],int size,int key){
for(int i=0;i<size;i++){
if(ara[i]==key){
cout<<key<<" has been found in place "<<i<<endl;
getch();
break;
}
else if(i==size-1&&ara[i]!=key){
cout<<-1;
getch();
break;
}
}
}
int main(){
int a;
int arraysize=50;
int array1[50];
int key;
while(true){
cout<<"\nEnter size of array: ";
cin>>a;
cout<<"Enter Array of numbers:(max 50)\n";
int i=0;
while(i!=a){
cin>>array1[i];
i++;
}
cout<<"Enter Key to find: ";
cin>>key;
finding(array1,arraysize,key);
}
return 0;
}
کسی نیست جواب بده لطفا راهنمایی کنیدنقل قول:
یک فایل ایجاد کنیدکه محتویات آن شامل کلمه ،حروف واعداد باشند و محتویات فایل راخوانده ومجموع هر کدام را محاسبه کندودر یک فایل دیگر نمایش دهد.