الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

إلى محبين التحدي

بدأه SABA'A في 16 نوفمبر 2008 · 4 رد · 620 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بســم الله الـرحمــن الرحيــم

مرحـــــبا

الفريق العربي للبرمجة

أنا طلب القرب من خلال المساعدة في هذا التحدي هذا التحدي عبارة عن كتبت برنامج يقوم بطابعة نفسه يعنى لو كتبت هذا الكود

include <iostream>#include <fstream>using namespace std; int main () { ofstream myfile; myfile.open ("example.txt"); myfile << "Writing this to a file.\n"; myfile.close(); return 0;}بقوم بطابعة كل هذا الكود

هذا التحدي من قبل أحد المدرسين فارجوا المساعدة يأهل الخبرة

وشكــــــــــــــــــــرررراً

#2

وعليكــم السـلام ورحمة الله وبركاتـه..

نساعدك في ماذا ..؟

برنامجك شكله بأخذ الكود من ملف ، ويقوم بطباعته على الشاشه ، ومحتويات الملف تكون هي السورس كود ،،

راجع هنا لطرق أخرى :

برنامج لطباعه السورس الكود لنفس البرنامج

بالتوفيق ،،

تم تعديل هذه المشاركة بواسطة Wajdy Essam في 16 نوفمبر 2008 في 12:40

http://informatic-ar.com منصة تعليمية عربية في علوم الحاسب والبرمجة

https://moalfat.com  للكتب الالكترونية والكورسات التعليمية

Everything we see now is just an engineering solution based on old science

#3

هذه طريقة أخرى تعتمد على ان المايكرو __FILE__ يعيد اسم ملف السورس نيم .

هذا الكود.

  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. string line;
  10. ifstream myfile (__FILE__);
  11. if (myfile.is_open())
  12. {
  13. while (! myfile.eof() )
  14. {
  15. getline (myfile,line);
  16. cout << line << endl;
  17. }
  18. myfile.close();
  19. }
  20.  
  21. cin.get();
  22.  
  23. return 0;
  24. }
  25.  

tvquran_6.gif

#4

هل تقصد عمل Quine ؟

اذا كان كذلك فهذا مثال بسيط

/* A simple quine (self-printing program), in standard C. */

/* Note: in designing this quine, we have tried to make the code clear
 * and readable, not concise and obscure as many quines are, so that
 * the general principle can be made clear at the expense of length.
 * In a nutshell: use the same data structure (called "progdata"
 * below) to output the program code (which it represents) and its own
 * textual representation. */

#include <stdio.h>

void quote(const char *s)
	 /* This function takes a character string s and prints the
	  * textual representation of s as it might appear formatted
	  * in C code. */
{
	int i;

	printf("	\"");
	for (i=0; s; ++i) {
		/* Certain characters are quoted. */
		if (s == '\\')
			printf("\\\\");
		else if (s == '"')
			printf("\\\"");
		else if (s == '\n')
			printf("\\n");
		/* Others are just printed as such. */
		else
			printf("%c", s);
		/* Also insert occasional line breaks. */
		if (i % 48 == 47)
			printf("\"\n	\"");
	}
	printf("\"");
}

/* What follows is a string representation of the program code,
 * from beginning to end (formatted as per the quote() function
 * above), except that the string _itself_ is coded as two
 * consecutive '@' characters. */
const char progdata[] =
	"/* A simple quine (self-printing program), in st"
	"andard C. */\n\n/* Note: in designing this quine, "
	"we have tried to make the code clear\n * and read"
	"able, not concise and obscure as many quines are"
	", so that\n * the general principle can be made c"
	"lear at the expense of length.\n * In a nutshell:"
	" use the same data structure (called \"progdata\"\n"
	" * below) to output the program code (which it r"
	"epresents) and its own\n * textual representation"
	". */\n\n#include <stdio.h>\n\nvoid quote(const char "
	"*s)\n	 /* This function takes a character stri"
	"ng s and prints the\n	  * textual representati"
	"on of s as it might appear formatted\n	  * in "
	"C code. */\n{\n	int i;\n\n	printf(\"	\\\"\");\n "
	"   for (i=0; s; ++i) {\n		/* Certain cha"
	"racters are quoted. */\n		if (s == '\\\\')"
	"\n			printf(\"\\\\\\\\\");\n		else if (s["
	"i] == '\"')\n			printf(\"\\\\\\\"\");\n		e"
	"lse if (s == '\\n')\n			printf(\"\\\\n\");"
	"\n		/* Others are just printed as such. */\n"
	"		else\n			printf(\"%c\", s);\n   "
	"	 /* Also insert occasional line breaks. */\n "
	"	   if (i % 48 == 47)\n			printf(\"\\\"\\"
	"n	\\\"\");\n	}\n	printf(\"\\\"\");\n}\n\n/* What fo"
	"llows is a string representation of the program "
	"code,\n * from beginning to end (formatted as per"
	" the quote() function\n * above), except that the"
	" string _itself_ is coded as two\n * consecutive "
	"'@' characters. */\nconst char progdata[] =\n@@;\n\n"
	"int main(void)\n	 /* The program itself... */\n"
	"{\n	int i;\n\n	/* Print the program code, cha"
	"racter by character. */\n	for (i=0; progdata[i"
	"]; ++i) {\n		if (progdata == '@' && prog"
	"data[i+1] == '@')\n			/* We encounter tw"
	"o '@' signs, so we must print the quoted\n	   "
	"	  * form of the program code. */\n		{\n "
	"		   quote(progdata);	/* Quote all. */\n"
	"			i++;				/* Skip second '"
	"@'. */\n		} else\n			printf(\"%c\", p"
	"rogdata);  /* Print character. */\n	}\n	r"
	"eturn 0;\n}\n";

int main(void)
	 /* The program itself... */
{
	int i;

	/* Print the program code, character by character. */
	for (i=0; progdata; ++i) {
		if (progdata == '@' && progdata[i+1] == '@')
			/* We encounter two '@' signs, so we must print the quoted
			 * form of the program code. */
		{
			quote(progdata);	/* Quote all. */
			i++;				/* Skip second '@'. */
		} else
			printf("%c", progdata);  /* Print character. */
	}
	return 0;
}
llback.jpg

اشهد ان لا إله إلا الله وان محمدا ً رسول الله

#5

هذه طريقة لطباعه كودك بالضبط .

  1. #include <iostream>
  2. using namespace std;
  3. int main(int argc, char *argv[])
  4. {
  5. int code[]={35,105,110,99,108,117,100,101,32,60,105,111,115,116,114,101,97,109,62,10,35,105,110
    ,99,108,117,100,101,32,60,102,115,116,114,101,97,109,62,10,117,115,105,110,103,32,110,97,109,10
    1,115,112,97,99,101,32,115,116,100,59,10,105,110,116,32,109,97,105,110,40,41,10,123,10,111,102,
    115,116,114,101,97,109,32,109,121,102,105,108,101,59,32,10,109,121,102,105,108,101,46,111,112,1
    01,110,32,40,34,101,120,97,109,112,108,101,46,116,120,116,34,41,59,32,10,109,121,102,105,108,10
    1,32,60,60,32,34,87,114,105,116,105,110,103,32,116,104,105,115,32,116,111,32,97,32,102,105,108,
    101,46,92,110,34,59,32,10,109,121,102,105,108,101,46,99,108,111,115,101,40,41,59,10,114,101,116
    ,117,114,110,32,48,59,10,125,10,-1};
  6. for(int i=0;i<188;i++,cout<<char(code[i]));
  7. cin.get();
  8. return 0;
  9. }
  10.  

tvquran_6.gif

مواضيع مشابهة