लक्ष्य
अपनी पसंद की प्रोग्रामिंग भाषा का उपयोग करते हुए, C प्रोग्राम का प्रतिनिधित्व करने वाले स्ट्रिंग से टिप्पणियों को समाप्त करने के लिए सबसे छोटा प्रोग्राम लिखें ।
इनपुट
स्ट्रिंग को इनपुट के किसी भी रूप के रूप में लिया जा सकता है, लेकिन इसे एक चर के रूप में भी लिया जा सकता है।
अनुदेश
दो अलग-अलग तरह की टिप्पणियों को हटाया जाना है:
- बहुस्तरीय टिप्पणी , के साथ शुरू
/*और समाप्त*/ //लिनक्स शैली लाइन के टूटने (LF\n) के साथ शुरू और समाप्त होने वाली एकल पंक्ति टिप्पणियाँ
स्ट्रिंग्स के भीतर टिप्पणियां नहीं हटाई जानी हैं। इस चुनौती के उद्देश्य के लिए, आपको केवल "-निर्धारित स्ट्रिंग्स पर विचार करने की आवश्यकता है । विशेष रूप से, आप '-delimited चरित्र शाब्दिक की संभावना को अनदेखा कर सकते हैं । आप ट्रिग्राफ और लाइन निरंतरता ( /\<LF>*...) को भी अनदेखा कर सकते हैं ।
उदाहरण
इनपुट:
#include <stdio.h>
int main(int argc, char** argv)
{
// this comment will be removed
if (argc > 1) {
printf("Too many arguments.\n"); // this too will be removed
return 1;
}
printf("Please vist http://this.will.not.be.removed.com\n");
printf("/* This will stay */\n");
printf("\"/* This will stay too */\"\n");
printf("//and so will this\\");
// but not this
printf("just \"ano//ther\" test.");
return 0;
}
आउटपुट:
#include <stdio.h>
int main(int argc, char** argv)
{
if (argc > 1) {
printf("Too many arguments.\n");
return 1;
}
printf("Please vist http://this.will.not.be.removed.com\n");
printf("/* This will stay */\n");
printf("\"/* This will stay too */\"\n");
printf("//and so will this\\");
printf("just \"ano//ther\" test.");
return 0;
}
इनपुट:
/*
this shall disappear
*/
#include <string>
int main(int argc, char** argv)
{
string foo = ""/*remove that!**/;
// Remove /* this
int butNotThis = 42;
// But do */ remove this
int bar = 4 /*remove this*/* 3; // but don't remove that 3. */
return 0;//just a comment
}/*end of the file has been reached.*/
आउटपुट:
#include <string>
int main(int argc, char** argv)
{
string foo = "";
int butNotThis = 42;
int bar = 4 * 3;
return 0;
}
// this comment will be removedजो बस गायब हो गए। उसके लिए कोई नियम?
printf("\"/* This will stay too */\"\n");में दिखाई दिया ?