Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Lab 7 blackjack v1.1
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//gcc 5.4.0 #include <stdio.h> //PRINT " Please input 2 integers" //int x; //int y; //int sum; //READ x and y //sum=x+y; //if(sum>21) // PRINT "You Lose\n"; //else //{ // while(sum<=21&&sum>=17) // { // READ x // sum=x+sum; // continue; // } //} //printf("%d\n",sum); //if(sum>21) // PRINT "You Lose :( \n"; //else // PRINT "YOU WIN!!!!! :)\n" int main(void) { printf("Please input 2 positive integers.\n"); int x; int y; int sum; int sum1; scanf("%d%d",&x,&y); if(x<0||y<0){ printf("There are no negative cards :["); return 0; } sum=x+y; // printf("%d\n",sum); if(sum>21) printf("%d\nYou Lose\n",sum); else { while(sum<17) { x=0; scanf("%d",&x); if(x<0){ printf("There are no negative cards :["); return 0; } if(x==0){ printf("There are no cards with 0 value :["); return 0; } sum1=sum; sum=x+sum; if(sum1==sum) break; printf("%d\n",sum); } if(sum>=17&&sum<=21){ printf("%d\nYOU WIN\n",sum); } else if(sum<=17){ printf("%d\n Draw another card\n",sum); } else if(sum>21){ printf("%d\nYOU LOSE\n",sum); } } }
gcc
2 9 9
Show compiler warnings
[
+
] Compiler args
[
-
]
Show input
Compilation time: 0.12 sec, absolute running time: 0.14 sec, cpu time: 0 sec, memory peak: 3 Mb, absolute service time: 0,35 sec
edit mode
|
history
|
discussion
Please input 2 positive integers. 20 20 YOU WIN