1struct Tumpukan
2{
3 char Isi[MaxElemen];
4 int Atas;
5} T;
6
7//sub program PUSH berfungsi memasukkan elemen ke dalam STACK
8void PUSH (char x){ //fungsi push
9if(T.Atas == MaxElemen){ //untuk mengecek apakah stack sudah penuh
10 cout<<"Tumpukan Sudah Penuh";
11 getch();
12}
13else{
14 T.Atas = T.Atas + 1;
15 T.Isi[T.Atas] = x;
16}
17}
1void reverse_list (solution & pi)
2{ vector<int >tour;
3 int pointer;
4 for (int i=0;i<=v_num-1;i++)
5 {
6 pointer=pi.sol[i][0];
7 while (pointer!=0)
8 {
9 tour.push_back(pointer);
10 pointer=pi.sol[i][pointer];
11 }
12 pi.sol_r[i][0]=tour.back();
13 tour.pop_back();
14 pointer=pi.sol_r[i][0];
15 while (tour.size())
16 {
17 pi.sol_r[i][pointer]=tour.back();
18 pointer=pi.sol_r[i][pointer];
19 tour.pop_back();
20 }
21 pi.sol_r[i][pointer]=0; }
22}
1#include <iostream>
2#include <string.h>
3int main (){
4 int i;
5 char telefone[20];
6 char ch;
7 i=0
8 while((ch=getchar ())) 1='\n') (
9 if (ch=='-')telefone[1]='-';
10 else if (ch >=48 && ch <=57) telefone [i]=ch;
11 else if (ch >=65 && ch <=67) telefone [i]='2';
12 else if (ch >=68 && ch <=70) telefone [i]='3';
13 else if (ch >=71 && ch <=73) telefone [i]='4';
14 else if (ch >=74 && ch <=76) telefone [i]='5';
15 else if (ch >=77 && ch <=79) telefone [i]='6';
16 else if (ch >=80 && ch <=83) telefone [i]='7';
17 else if (ch >=84 && ch <=86) telefone [i]='8';
18 else if (ch >=87 && ch <=90) telefone [i]='9';
19
20 i++;
21 }
22 telefone[i]='\0';
23 printf("%s", telefone);
24 return(0);
25}
1#include<iostream>
2using namespace std;
3
4int dado() {
5
6 return rand() % 6 + 1;
7}
8
9void casasEspeciais( int player){
10 switch (player) {
11 case 3:
12 player = 16;
13 break;
14 case 5:
15 player = 7;
16 break;
17 case 15:
18 player = 25;
19 break;
20 case 18:
21 player = 20;
22 break;
23 case 21:
24 player = 32;
25 break;
26 case 12:
27 player = 2;
28 break;
29 case 14:
30 player = 11;
31 break;
32 case 17:
33 player = 4;
34 break;
35 case 31:
36 player = 19;
37 break;
38 case 35 :
39 player = 22;
40 break;
41 default:
42 break;
43 }
44}
45
46void regrasDoJogo(int p1,int p2, int &c1, int &c2) {
47 p1 = 1;
48 p2 = 1;
49 bool game = true;
50 int jogadas = 0;
51
52 while (game)
53 {
54 p1 += dado();
55 casasEspeciais(p1);
56
57 if (p1 >= 36) {
58 c1++;
59
60 game = false;
61 break;
62 }
63 p2 += dado();
64 casasEspeciais(p2);
65
66 if (p2 >= 36){
67 c2++;
68
69 game = false;
70 break;
71 }
72 jogadas++;
73 };
74
75}
76
77int player1, player2;
78int count1, count2;
79
80float TOTAL = 10000.0f;
81
82int main() {
83 count1 = 0;
84 count2 = 0;
85
86 srand(time(NULL));
87
88 for (int i = 0; i < TOTAL; i++){
89 regrasDoJogo(player1, player2, count1, count2);
90
91 }
92 cout << "vitorias do p1:" << count1 << endl;
93 cout << "vitorias do p2:" << count2 << endl;
94
95 float porcentagem = (count1 / TOTAL)*100;
96
97 cout << "a probabilidade do primeiro ganhar é de:" << porcentagem <<"%"<< endl;
98
99 system("pause");
100 return 0;
101}
1#include <iostream>
2
3using namespace std;
4
5int main()
6
7{ int n=4,num-n-1; for(int i=1;i<n;i++) {
8
9for(int j=1;j<=i;j++) cout<<num; cout<<endl;
10
11num++;
12
13}
14
15num-;
16
17for(int i=n;i>=1;i-)
18
19{ for(int j=1;j<=i;j++) cout<<num; num--; cout<<endl;
20
21}
22
23return 0;
24
25}
1int main() {
2for(int i=1; i<20;i++) {
3sum=A+1;
4} ;
5for(i=1; i>5; i++) {
6if A!=sum {
7B=B+A;
8} ;
9} ;
10
1#include "stdafx.h"
2#include <iostream>
3#include <Windows.h>
4#include <time.h>
5
6
7using namespace std;
8
9
10int main()
11{
12 cout << "===============================================================================" << endl;
13 cout << "External Rapid Fire by EPiC REV (Copyright 2013 @ EPiC REV). Works in any game!" << endl;
14 cout << "===============================================================================" << endl;
15 cout << "Press right-click in game to rapid fire." << endl;
16
17
18 bool RapidFire = false;
19 int AutoFireTimer = clock();
20 int currentTime;
21 bool MouseDown = false;
22 while(true)
23 {
24 //Check for right mouse button to be down.
25 if(GetAsyncKeyState(VK_RBUTTON) & 0x8000)RapidFire = true;
26 else RapidFire = false;
27
28
29 if(RapidFire)
30 {
31 //only go if so many milliseconds have passed.
32 if(!MouseDown)
33 {
34 MouseDown = true;
35 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //
36 }
37 if(clock() - AutoFireTimer > 21)
38 {
39 MouseDown = false;
40 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); //
41 AutoFireTimer = clock();
42 }
43 }
44 }
45
46}
1#include <iostream>
2using namespace std;
3long long sort(arr,arr+n,greater<int>());
4
5int main() {
6 // your code goes here
7 int T;
8 cin>>T;
9 for(int ts=0; ts<T; ts++)
10 {
11 long long int sum=0,n;
12 cin>>n;
13 long long int arr[n];
14 for(long long int i=0; i<n; i++)
15 cin>>arr[i];
16 sort(arr[i],arr+n,greater<int>());
17 for(long long int k=0; k<n; k++)
18 {
19 if(k==0)
20 {
21 sum=arr[k];
22 }
23 else if (arr[k]-k>=0)
24 {
25 sum=sum+arr[k]-k;
26 }
27 else {
28 break;
29 }
30 }
31 cout<<sum<<end1;
32 }
33 return 0;
34}
35
1#include <iostream>
2#include <vector>
3#include <algorithm>
4using namespace std;
5void obradi(const vector<int>& particija, int k) {
6 for (int i = 0; i < k; i++)
7 cout << particija[i] << " ";
8 cout << endl;
9}
10void obradiParticije(int n, int smax, vector<int>& particija, int k) {
11 if (n <= 0)
12 obradi(particija, k);
13 else {
14 for (int s = 1; s <= min(n, smax); s++) {
15 particija[k] = s;
16 obradiParticije(n-s, s, particija, k+1);
17 }
18}
19void obradiParticije(int n) {
20 vector<int> particija(n);
21 obradiParticije(n, n, particija, 0);
22}
23int main() {
24 int n;
25 cin >> n;
26 obradiParticije(n);