Created
September 17, 2014 09:02
-
-
Save metrafonic/f31f42bc68d2519eb43a to your computer and use it in GitHub Desktop.
Oppgave1.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
#include <stdlib.h> | |
#include <conio.h> | |
int main(){ | |
int x=1; | |
int y = 1; | |
int i, j, z, nr1, nr2, nr3, nr4; | |
printf("Oppgave a): \n"); | |
for (i=0; i<7; i++){ | |
for(j=0; j<x; j++){ | |
printf("*"); | |
} | |
x=x*2; | |
printf("\n"); | |
} | |
getch(); | |
printf("\nOppgave b): \n"); | |
x=1; | |
y = 1; | |
z=0; | |
printf("*\n"); | |
for (i=0; i<6; i++){ | |
x=x*2-i; | |
for(j=0;j<x; j++){ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
getch(); | |
printf("\nOppgave c): \n"); | |
x=1; | |
y = 1; | |
z=0; | |
nr1=1; | |
nr2=1; | |
nr3=1; | |
printf("*\n"); | |
for (i=0; i<7; i++){ | |
if(i>=2){ | |
x=x*2-nr3; | |
//printf("-%i ",nr3); | |
}else{ | |
x=x*2; | |
} | |
nr3=nr2; | |
nr2=nr1; | |
nr1=x; | |
//printf("%i", x); | |
for(j=0;j<x; j++){ | |
printf("*"); | |
} | |
printf("\n"); | |
} | |
getch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment