theakhilarya's blog

By theakhilarya, history, 3 years ago, In English

Hi! I am new to data structures.

I am trying to make a linked list using a for loop. I was expecting output to be 1 2 3 4 5 instead I am getting 0 as output.

Can someone please explain my mistake?

#include <iostream>

using namespace std;

class Node
{
public:
	int data;
	Node* next;
};

void printLL(Node* n)
{
	while (n != NULL)
	{
		cout << n->data << " ";
		n = n->next;
	}
}

int main()
{
	int value;
	Node *head, *newNode = NULL, *temp = NULL;
	for (int i = 1; i <= 5; i++)
	{
		head = new Node();
		newNode = new Node();
		if (i == 1) //for the first node
		{
			head->data = i;
			head->next = newNode;
		}
		else //for the rest of the nodes
		{
			newNode->data = i;
			newNode->next = NULL;
		}
	}
	printLL(head);

	return 0;
}

Full text and comments »

  • Vote: I like it
  • -32
  • Vote: I do not like it

By theakhilarya, history, 3 years ago, In English

I want to compare four integers and see whether they are equal or not. So wrote the following,

int a = 1, b = 2, c = 3, d = 4;
if (a != b != c != d)
{
    //do something
}

This apparently shows no error. But, in fact, giving the wrong answer. Can someone explain this, please?

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

By theakhilarya, history, 3 years ago, In English

I was learning operators in C++. I wrote this program in MS Visual 2019.

int i = 0;
cout << i << endl << i++ << endl << ++i;

Output:

2
1
2

But, I expected the output to be:

0
0
2

or maybe:

0
1
2

Why, when printing just i is not zero. Can someone explain this? Thanks

Full text and comments »

  • Vote: I like it
  • -24
  • Vote: I do not like it

By theakhilarya, history, 3 years ago, In English

I use Visual Studio 2019 for coding. I have been it till now for codeforces. But from yesterday whenever I am uploading my source file it shows this error. Can anyone help me fix this. Thank You.

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31321.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{6C54A1FC-6190-4E26-B1BF-F567058944CF}"
EndProject


Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|x64 = Debug|x64
		Debug|x86 = Debug|x86
		Release|x64 = Release|x64
		Release|x86 = Release|x86
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{6C54A1FC-6190-4E26-B1BF-F567058944CF}.Debug|x64.ActiveCfg = Debug|x64
		{6C54A1FC-6190-4E26-B1BF-F567058944CF}.Debug|x64.Build.0 = Debug|x64
		{6C54A1FC-6190-4E26-B1BF-F567058944CF}.Debug|x86.ActiveCfg = Debug|Win32
		{6C54A1FC-6190-4E26-B1BF-F567058944CF}.Debug|x86.Build.0 = Debug|Win32
		{6C54A1FC-6190-4E26-B1BF-F567058944CF}.Release|x64.ActiveCfg = Release|x64
		{6C54A1FC-6190-4E26-B1BF-F567058944CF}.Release|x64.Build.0 = Release|x64
		{6C54A1FC-6190-4E26-B1BF-F567058944CF}.Release|x86.ActiveCfg = Release|Win32
		{6C54A1FC-6190-4E26-B1BF-F567058944CF}.Release|x86.Build.0 = Release|Win32
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {3B3C5184-DF9A-4834-A3AB-7986C56EB7DF}
	EndGlobalSection
EndGlobal

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By theakhilarya, history, 3 years ago, In English

Hi! I am new to codeforces. Yesterday I participated in my first contest Educational Codeforces Round 110 (Rated for Div. 2). And solved only the first question. Yes, I am new to CP. My rating is still missing. The only Rated section is empty and in All section mention the contest but it shows "= 0 (unrated newbie).

Is there a minimum number of contests I have to do to get my rating and why Educational Codeforces Round 110 (Rated for Div. 2) is showing up in ALL rather than Rated?

Sorry, It is basic, but I am new here.

Thanks!

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By theakhilarya, history, 3 years ago, In English

on Test 28

INPUT : a z

Output : wrong output format Unexpected end of file — token expected

Desired Output : -1

I am getting the right answer in VS2019. But in codeforce IDE it shows error. What to do? Please help, thanks!

#include <iostream>
using namespace std;
int main()
{	
	string a, b;
	int a1,b1,count = 0, diff = 0;
	cin >> a >> b;
	int size = a.size();
	for (int i = 0; i < size; i++)
	{
		int a1 = a[i];
		int b1 = b[i];
		if (a1 == b1 || a1 == (b1 + 32) || (a1 + 32) == b1)
			count++;
		else
		{
			if (a1 > 90 && b1 > 90)
				diff = a1 - b1;
			else if (a1 <= 90 && b1 <= 90)
				diff = a1 - b1;
			else if (a1 > 90 && b1 < 90)
				diff = (a1 - 32) - b1;
			else if (a1 < 90 && b1 > 90)
				diff = (a1) - (b1 - 32);
			break;
		}
	}
	if (count == size)
		cout << "0";
	else if (diff > 0)
		cout << "1";
	else if (diff < 0)
		cout << "-1";
	
	
	return 0;
}

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it