Thursday, 22 December 2011

Learning C++


Learning C++

See "FAQs" above; see also "C++ resources", "consulting services",
"everything sites" and "Websites for authors of C++ books and
articles" below.



The C++ language from its basics up to the newest features of ANSI-C++,
including basic concepts such as arrays or classes and advanced
concepts such as polymorphism or templates. My personal favorite
you just cannot miss this site when doing something serious with C++
http://www.cplusplus.com/ 
 
 
 
 
 


A web site designed to help you learn the C or C++ programming
languages, and provide you with C and C++ programming language
resources.
http://www.cprogramming.com/ 
 
 
Tutorials about C++
http://cplus.about.com/ 
 
C++ Annotations (moving from C to C++)
http://www.icce.rug.nl/documents/cplusplus/ 

DevCentral tutorials for C and C++
http://devcentral.iftech.com/learning/tutorials/ 

C++ tutorials for Windows 32, how to do without MFC, getting the compiler
to do the hard work of avoiding memory leaks, games, frequency analysis etc
http://www.relisoft.com/ 

Coronado enterprises tutorials (formerly Gordon Dodrill's)
You can see sample chapters, but are charged for the full tutorials
http://www.coronadoenterprises.com/ 

Guru of the week - ie discussion papers on using C++
http://www.cntc.com/resources/gotw.html 

Tutorials etc on Borland's CBuilder
http://www.richplum.co.uk/cbuilder/ 

Tutorial on the STL by Phil Ottewell.
http://www.yrl.co.uk/~phil/stl/stl.htmlx 
http://www.pottsoft.com/home/stl/stl.htmlx 
He has also got a tutorial on C for Fortran users
http://www.pottsoft.com/home/c_course/course.html 

Notes for a university lecture course, but
maybe there is enough here for independent study. 
http://m2tech.net/cppclass/ 

Note on pointers - perhaps more oriented towards C than C++.
http://www.cudenver.edu/~tgibson/tutorial/ 

Very simple C under DOS or MS-windows. Not much C++;
possibly useful to someone interested in programming
MS-windows without MFC etc.
http://www.cpp-programming.com 

Weekly newsletter on C++ and other things: aimed at helping new
and intermediate programmers improve their coding skills.
http://www.cyberelectric.net.au/~collins 

www.informit.com - a site run by Macmillan USA containing a lot
of information including the several well-known C++ books for
free download - if you are prepared to supply name and email address 
http://www.informit.com/ 

C++ in 21 days - 2nd edition
http://newdata.box.sk/bx/c/ 

A variety of C++ books on line (Macmillian, Sams, Wiley, IDG etc)
You can see the tables of contents, but you will have to have a
subscription to read the books themselves after a free trial.
http://www.itknowledge.com/reference/dir.programminglanguages.c1.html 

Elementary introduction to C++ (mostly the C subset)
http://clio.mit.csu.edu.au/TTT/ 

How to use function-pointers in C and C++, callbacks, functors
http://www.function-pointer.org 
http://www.newty.de/fpt/fpt.html 

Short C++ tutorial, aimed at people who already have
experience with an object-oriented programming language
http://www.entish.org/realquickcpp/ 

Articles about Win32, C++, MFC articles using VC++ compiler. 
http://www.codersource.net 

Wednesday, 14 December 2011

2727. ARMY STRENGTH

Summary:- 
Well problem is pretty simple.... Both Godzilla and MechaGodzilla have soldiers of different strength and there will be random fight between individual soldiers and winner in this fight will be based on simple condition-->
Strength of Godzilla soldier >= Strength of MechaGodzilla soldier(obviously... Godzilla one wins)
Strength of Godzilla soldier < Strength of MechaGodzilla soldier(obviously... MechaGodzilla one wins)
Otherwise "uncertain"(Yup... you are right.... this never happens) 

 This continues for every soldier and the team whose soldiers remain is declared winner by the above mentioned criteria.

Logic:-
What I did is I took input of strengths in an array of required size and then found out the greatest integer in both the array and then compared it according the above criteria to score an AC
Here's the code in C.


#include<stdio.h>
int main()
{
 int t;
 scanf("%d",&t);
 int i;
 int j;
 int ng;
 int nm;
 int m1;
 int m2;
 for(i=0;i<t;i++) {
  scanf("%d",&ng);
  scanf("%d",&nm);
  int g[ng];
  int m[nm];
  for(j=0;j<ng;j++) {
   scanf("%d",&g[j]);
  }
  for(j=0;j<nm;j++) {
   scanf("%d",&m[j]);
  }
  m1=g[0];
  m2=m[0];
  for(j=1;j<ng;j++) {
   if(m1<g[j])
   m1=g[j];
  }
  for(j=1;j<nm;j++) {
   if(m2<m[j])
   m2=m[j];
  }
  if(m1>=m2)
   printf("Godzilla\n");
  else if(m1<m2)
   printf("MechaGodzilla\n");
  else
   printf("uncertain\n");
 }
 return 0;
}