Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Variables Declaradas Antes de Su Uso
Variables Declaradas Antes de Su Uso
#INCLUDE <stdio.h>
Main()
{
printf (hola mundo);
}
%d entero
%f real
%6,2f
Loops
While (expresin ){
Orden;
}
For (exp1;exp2;exp3){
Orden
}
#include <stdio.h>
Int power(int a,int base);
Main ()
{
Int x=power(int a;int b);
Printf (la wa %d , x);
Return 0
Sino retorno nada se return cero
}
Int x=10
Int power (int a , int base)
{
Int i;
Int P=1;
For (i=1;i<a;i=i+1)
P=p*base;
Return p;
}
ARREGLOS
Declaracin
Char
cosa[largo n]
Int
cosa[larguito]
Funcin len
Int len(char palabra[])
{
Int i;
i=0;
while (palabra[i]!=o/ )
i=i+1;
return i ;
}
Funcin conversin
Int con(char s[])
{
Int i ,n=0;
For (i=0;s[i]>0&&s[i]=<9,i=i+1)
N=n*10+(s[i]-0);
Return n;
}
PUNTEROS
c=&p
*p
Int strlen(*p,a[])
{
Int n;
For(n=0;*s!=/0;s=s+1)
N=n+1;
Return n;
}
ESTRUC TURAS
Ej
Struct point{
Int x;
Int y ;
}
Struct rect{
Struct point pt1;
Struct point pt2;
}
Listas
Struct nodo
..
{
Int data;
Struct node*next;
}nodo
Lista3 {
Struct nodo *one=null;
Struct nodo *two=null;
Struct nodo *three=null;
One = malloc(sizeof(struct nodo));
Two=malloc(sizeof(struct nodo));
Three =malloc(sizeof(struct nodo);
Onedata=n1
One next=two
Two data=n2
Two next=three
Three data=n3
Three next=null
Return one
}
{
Int count=0;
Struct nodo *now=lista;
While (*now!=null)
{
now=nownext;
Count=count+1;
}
}
Newnodenext=one
ONE =newnode;
}
Free(head);
Return result
}
Stack
Typedef struct stack{
Int dato;
Int tems[maxsize];
}stack;
Pop(stack **head){
Int result;
If (empty(head)){
Fputs(error : stacks is underflows,stderr);
Abort();
}else{
Stack *top =*head
Result= *headdato
*head=*topnext
Free (top)
}}
Return(true);
}else{
If (target>nododata){
Return (lookup(nodeleft,target);
}else{ Return (lookup(noderight,target));
}}}
{While( p!=null)
{
If (pnkey==clave) {return pn;}
Else{if (pnkey>clave;){pnright;
}else{pnleft;}return pn}}
Return pa;}
Nodo Buscarmenosdesendiente(*pn)
{
If (pn==null ||pnright==null)
{return (null)}
Else {
Return(buscarminimo(nodo pnright)}}
Tarea
Altura numero de hojas nodos unir dos arboles
Void listareversa(**a){
M=len(*p)
Struct nodo temp=*a
Struct node *newlist=null
While(m!=0){
Int i ;
For (i=1,i<=m,i++)
{temp=tempnext;}
Newnode(*newlist,tempdata)
m
}
Void newnode(*lista,int dato)
{ temp=malloc(sizeof(structnodo))
Struct nod temp1=lista
If (lista==null)
Tempdata=dato
Tempnext=null
Lista=temp
}else{
While(temp1next!=null){
Temp1=temp1next
}temp1next=temp
Tempdata=dato
Tempnext=null
}}