اینجا کسی برنامه نویسی سی پلاس پلاس بلده؟

  • نویسنده موضوع دکترگوگولی
  • تاریخ شروع
دکترگوگولی

دکترگوگولی

کاربر نمونه
Ms
تاریخ ثبت‌نام
25/4/23
نوشته‌ها
210
پسندها
143
امتیازها
43
مدال ها
3
جنسیت
خانم👩
برای چهار تا کد کمک می خوام
زبان سی پلاس پلاس خودم هم بلدم
اولین پروژه ام هست
منتها از شانسم یارو کد گرافیکی می خواد
با کتابخونه graphic.h
و من خیلی کد کار کردم الا این
از چت چی پی تی کمک گرفتم جواب نداد
میشه شما کمکم کنید کد درست برام بنویسید
من ببینم چی به چیه و کدهام تغییر بدم
دمتون گرم
قبول زحمت کنید ۴۰۰ تا صلوات می فرستم براتون‌.
خروجی کد ها این عکس ها باید بشه:
20240523 160307
IMG 20240522 201843 915
20240519 150707
IMG 20240518 222008 626
 
دکترگوگولی

دکترگوگولی

کاربر نمونه
Ms
تاریخ ثبت‌نام
25/4/23
نوشته‌ها
210
پسندها
143
امتیازها
43
مدال ها
3
جنسیت
خانم👩
❤️ آبجی شما می تونید کمکم کنید؟🥲
@اعتصامی
 
اعتصامی

اعتصامی

هلنم کاش بمونی تو برام
مدیر کل
تاریخ ثبت‌نام
4/10/22
نوشته‌ها
23,908
پسندها
22,820
امتیازها
113
مدال ها
6
دکترگوگولی

دکترگوگولی

کاربر نمونه
Ms
تاریخ ثبت‌نام
25/4/23
نوشته‌ها
210
پسندها
143
امتیازها
43
مدال ها
3
جنسیت
خانم👩
دکترگوگولی

دکترگوگولی

کاربر نمونه
Ms
تاریخ ثبت‌نام
25/4/23
نوشته‌ها
210
پسندها
143
امتیازها
43
مدال ها
3
جنسیت
خانم👩
اعتصامی

اعتصامی

هلنم کاش بمونی تو برام
مدیر کل
تاریخ ثبت‌نام
4/10/22
نوشته‌ها
23,908
پسندها
22,820
امتیازها
113
مدال ها
6
دکترگوگولی

دکترگوگولی

کاربر نمونه
Ms
تاریخ ثبت‌نام
25/4/23
نوشته‌ها
210
پسندها
143
امتیازها
43
مدال ها
3
جنسیت
خانم👩
من کدهام هم اینجا می ذارم
کد تصویر اول
#include <graphics.h>

int main() {
int gd = DETECT, gm;
// Initialize the graphics system
initgraph(&gd, &gm, NULL);

int left = 100; // Left coordinate of the square
int top = 100; // Top coordinate of the square
int right = 200; // Right coordinate of the square
int bottom = 200; // Bottom coordinate of the square

// Draw the square using rectangle function
rectangle(left, top, right, bottom);

// Draw diagonal lines (hatching) inside the square
for (int i = left; i <= right; i += 10) {
// Upper left to lower right diagonal
line(i, top, right, top + (i - left));
// Lower left to upper right diagonal
line(i, bottom, right, bottom - (i - left));
}
for (int j = top; j <= bottom; j += 10) {
// Upper left to lower right diagonal
line(left, j, left + (j - top), bottom);
// Upper right to lower left diagonal
line(right, j, right - (j - top), bottom);
}

getch(); // Wait for the user's input
closegraph(); // Close the graphics window

return 0;
}
کد تصویر دوم
#include <graphics.h>

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, NULL); // Initialize the graphics system

// Drawing a square
int topLeftX = 100, topLeftY = 100;
int bottomRightX = 300, bottomRightY = 200;
rectangle(topLeftX, topLeftY, bottomRightX, bottomRightY);

// Drawing filled rectangles and arcs inside the square
for (int i = 50; i <= 100; i += 50) {
setfillstyle(SOLID_FILL, LIGHTGRAY);
bar(topLeftX + i, topLeftY, bottomRightX - i, bottomRightY);

setcolor(WHITE);
// Calculate radius for arcs
int radius = (bottomRightX - topLeftX) / 2 - i;
// Draw arcs in the top-left and bottom-right corners
arc(topLeftX + radius, topLeftY, 0, 90, radius); // Arc from top-left corner
arc(bottomRightX - radius, bottomRightY, 180, 270, radius); // Arc from bottom-right corner
}

getch(); // Wait for a key press
closegraph(); // Close the graphics mode
return 0;
}
 
دکترگوگولی

دکترگوگولی

کاربر نمونه
Ms
تاریخ ثبت‌نام
25/4/23
نوشته‌ها
210
پسندها
143
امتیازها
43
مدال ها
3
جنسیت
خانم👩
کد تصویر سوم
#include <graphics.h>

int main() {
int gd = DETECT, gm;
// Initialize the graphics system
// Note: The third argument of initgraph should be the path to the BGI drivers.
// "" usually works, but you may need to specify the actual path depending on your setup.
initgraph(&gd, &gm, "");

int centerX = getmaxx() / 2;
int centerY = getmaxy() / 2;
int side = 200; // length of the square's side
int halfSide = side / 2;

// Coordinates of the square
int topLeftX = centerX - halfSide;
int topLeftY = centerY - halfSide;
int bottomRightX = centerX + halfSide;
int bottomRightY = centerY + halfSide;

// Draw the square
rectangle(topLeftX, topLeftY, bottomRightX, bottomRightY);

// Draw the diamond (lozenge)
line(centerX - halfSide, centerY, centerX, centerY - halfSide); // left to top
line(centerX, centerY - halfSide, centerX + halfSide, centerY); // top to right
line(centerX + halfSide, centerY, centerX, centerY + halfSide); // right to bottom
line(centerX, centerY + halfSide, centerX - halfSide, centerY); // bottom to left

// Draw inner lines parallel to diamond sides
// Since we want a star, we only need to draw the two main diagonals
line(centerX - halfSide, centerY, centerX + halfSide, centerY); // Horizontal line
line(centerX, centerY - halfSide, centerX, centerY + halfSide); // Vertical line

getch(); // Wait for a key press
closegraph(); // Close the graphics mode
return 0;
}
 
دکترگوگولی

دکترگوگولی

کاربر نمونه
Ms
تاریخ ثبت‌نام
25/4/23
نوشته‌ها
210
پسندها
143
امتیازها
43
مدال ها
3
جنسیت
خانم👩
کد تصویر چهارم
#include <graphics.h>

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, NULL); // Initialize the graphics system

int maxWidth = getmaxx();
int maxHeight = getmaxy();

// Coordinates for the vertices of the star (square turned 45 degrees)
int x1 = maxWidth / 2, y1 = maxHeight / 4;
int x2 = 3 * maxWidth / 4, y2 = maxHeight / 2;
int x3 = maxWidth / 2, y3 = 3 * maxHeight / 4;
int x4 = maxWidth / 4, y4 = maxHeight / 2;

// Draw lines to form the star
line(x1, y1, x3, y3);
line(x2, y2, x4, y4);

getch(); // Wait for a key press
closegraph(); // Close the graphics mode
return 0;
}
 
دکترگوگولی

دکترگوگولی

کاربر نمونه
Ms
تاریخ ثبت‌نام
25/4/23
نوشته‌ها
210
پسندها
143
امتیازها
43
مدال ها
3
جنسیت
خانم👩
کد تصویر چهارم
#include <graphics.h>

int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, NULL); // Initialize the graphics system

int maxWidth = getmaxx();
int maxHeight = getmaxy();

// Coordinates for the vertices of the star (square turned 45 degrees)
int x1 = maxWidth / 2, y1 = maxHeight / 4;
int x2 = 3 * maxWidth / 4, y2 = maxHeight / 2;
int x3 = maxWidth / 2, y3 = 3 * maxHeight / 4;
int x4 = maxWidth / 4, y4 = maxHeight / 2;

// Draw lines to form the star
line(x1, y1, x3, y3);
line(x2, y2, x4, y4);

getch(); // Wait for a key press
closegraph(); // Close the graphics mode
return 0;
}
 
بالا