Advertisement
Guest User

Array Program

a guest
May 16th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.04 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <conio.h>
  4. #include <iostream.h>
  5. #include <stdio.h>
  6. #include <windows.h>
  7. void setcolor(unsigned short color)
  8. {
  9. HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
  10. SetConsoleTextAttribute(hCon,color);
  11. }
  12.  
  13.  
  14. main()
  15. {
  16. system ("title Tugas Kelompok 7 Struktur Data");
  17. char lagi;
  18. int indeks,test,r,username,password,ex;
  19. float x;
  20. int q[1000];
  21. int tugasss[4]=
  22. {1,2,3,4};
  23. char tugass[7] =
  24. {'A','M','I','K','B','S','I'};
  25. float tugas[7]=
  26. {1.3,2,3.3,4,5.7,8,9.9};
  27.  
  28.  
  29.  
  30.  
  31. cout << "--------------------------------------------------------------------------------";
  32. cout << "=============| Pogram untuk membaca input password dari user |==================";
  33. cout << "--------------------------------------------------------------------------------";
  34. int user = 123;
  35. int pass = 123;
  36. ex = 1;
  37. do {
  38. cout <<"\n";
  39. cout << "Username : ";
  40. cin >> username;
  41. cout << "Password : ";
  42. cin >> password;
  43. cout <<"\n";
  44. if (username == user && password == pass) {
  45. cout << "============================ \n";
  46. cout << "Anda Berhasil Login" << endl;
  47. cout << "============================ \n\n";
  48. } else
  49. {
  50.  
  51. cout << "\n====================================\n";
  52. cout << "Maaf USERNAME & PASSWORD ANDA Salah!" << endl;
  53. cout << "====================================\n\n";
  54. ex = ex +1;
  55. }
  56. }
  57. while (ex <= 3);
  58. cout << "Anda Telah 3x Memasukan ID & PASSWORD Yang Salah\n";
  59. cout << "Mohon Maaf kesempatan Anda hanya 3x ";
  60.  
  61. if (username == user && password == pass) {
  62. cout << "============================ \n";
  63. cout << "Anda Berhasil Login" << endl;
  64. cout << "============================ \n\n";
  65.  
  66.  
  67. }
  68.  
  69.  
  70.  
  71.  
  72. setcolor(11);
  73. cout<<endl;
  74. char a[]={"\tWELCOME TO ONE DIMENSIONAL ARRAY PROGRAM\n"};
  75. char b[]={"\t\t PRESENT BY GROUP 7\n"};
  76. int i;
  77. double j;
  78. for(i=0;a[i]!='\0';i++){
  79. printf("%c",a[i]);
  80. for(j=0;j<=19999999;j++){
  81. }
  82. }
  83. for(i=0;b[i]!='\0';i++){
  84. printf("%c",b[i]);
  85. for(j=0;j<=19999999;j++){
  86. }
  87. }
  88.  
  89. cout<<endl;
  90. cout<<endl;
  91. setcolor(10);
  92. char c[]={"\t\t12151111\tARDIANSYAH\n"};
  93. for(i=0;c[i]!='\0';i++){
  94. printf("%c",c[i]);
  95. for(j=0;j<=19999999;j++){
  96. }
  97. }
  98. cout<<endl;
  99. char d[]={"\t\t12151111\tFIKI\n"};
  100. for(i=0;d[i]!='\0';i++){
  101. printf("%c",d[i]);
  102. for(j=0;j<=19999999;j++){
  103. }
  104. }
  105. cout<<endl;
  106. char e[]={"\t\t12153528\tJAMALUDIN\n"};
  107. for(i=0;e[i]!='\0';i++){
  108. printf("%c",e[i]);
  109. for(j=0;j<=19999999;j++){
  110. }
  111. }
  112. cout<<endl;
  113. char f[]={"\t\t12151692\tANISA SAFITRI\n"};
  114. for(i=0;f[i]!='\0';i++){
  115. printf("%c",f[i]);
  116. for(j=0;j<=19999999;j++){
  117. }
  118. }
  119. cout<<endl;
  120. char g[]={"\t\t12150854\tSALWA SRI DUNYA\n"};
  121. for(i=0;g[i]!='\0';i++){
  122. printf("%c",g[i]);
  123. for(j=0;j<=19999999;j++){
  124. }
  125. }
  126.  
  127.  
  128. clrscr();
  129.  
  130. //deklarasi string x
  131. setcolor(27);
  132. char k[]="PLEASE WAIT...PROGRAM IS BEING STARTED!!!";
  133. //deklarasi variabel bertipe integer
  134. int l,m,n;
  135.  
  136. //perulangan 5x untuk memunculkan string x sebanyak 5x
  137. for(n=0; n<5; n++)
  138. {
  139. //clear screen
  140. system("cls");
  141. //perulangan untuk menimbulkan jeda waktu
  142. for(l=0; l<199999;l++)
  143. {
  144. for(m=0; m<1999; m++)
  145. {
  146. }
  147. }
  148. //mencetak string k
  149. printf("\n\n%s",k);
  150. //perulangan untuk menimbulkan jeda waktu
  151. for(l=0; l<199999;l++)
  152. {
  153. for(m=0; m<1999; m++){
  154. }
  155. }
  156. }
  157.  
  158. mulai:
  159. clrscr();
  160. cout<<endl;
  161. setcolor(12);
  162. cout<<"\t SELAMAT DATANG \n";
  163. cout<<"\t MENU ARRAY DIMENSI SATU \n";
  164. cout<<"\t KELOMPOK TUJUH \n";
  165. cout<<endl;
  166. setcolor(11);
  167. cout<<"\t1. Inisialisasi Array Part I \n";
  168. cout<<"\t2. Inisialisasi Array Part II \n";
  169. cout<<"\t3. Inisialisasi Array Part III \n";
  170. cout<<"\t4. Inisialisasi Array Part IV \n";
  171. cout<<"\t5. Keluar \n";
  172. cout<<endl;
  173. setcolor(9);
  174. cout<<"\tMasukan Program Yang di Pilih [1,2,3,4] = ";cin>>test;
  175. switch(test)
  176. {
  177.  
  178. case 1:
  179. clrscr();
  180. {
  181. cout<<endl;
  182. setcolor(12);
  183. cout<<"\tInisialisasi Array Part I"<<endl;
  184. cout<<endl;
  185. setcolor(11);
  186. for (char t = 0; t < 7; t++)
  187. {
  188. cout<<"\tElemen Array Ke ["<<(t+1)<<"] = "<<tugass[t]<<endl;
  189. }
  190. cout<<endl;
  191. cout<<"\tPlease Enter To Continue...";
  192. getch();
  193. clrscr();
  194. cout<<endl;
  195. setcolor(9);
  196. cout<<"\tIngin Input Lagi[Y/T] : ";
  197. cin>>lagi;
  198. if(lagi=='Y' ||lagi=='y')
  199. goto mulai;
  200. break;
  201. }
  202.  
  203.  
  204. case 2:
  205. clrscr( );
  206. {
  207. cout<<endl;
  208. setcolor(12);
  209. cout<<"\tInisialisasi Array Part II "<<endl;
  210. cout<<endl;
  211. setcolor(11);
  212. for (int t = 0; t < 4; t++)
  213. {
  214. cout<<"\tElemen Array ke ["<<(t+1)<<"] = "<<tugasss[t]<<endl;
  215. }
  216. tugasss[0]=7;
  217. tugasss[1]=8;
  218. tugasss[2]=9;
  219. tugasss[3]=10;
  220. cout<<endl;
  221. cout<<"\tInisialisasi Aray Yang Baru :"<<endl;
  222. cout<<endl;
  223. for (int t = 0; t < 4; t++)
  224. {
  225. cout<<"\tElemen Array Ke ["<<(t+1)<<"] = "<<tugasss[t]<<endl;
  226. }
  227. cout<<endl;
  228. cout<<"\tPlease Enter To Continue...";
  229. getch();
  230. clrscr();
  231. cout<<endl;
  232. setcolor(9);
  233. cout<<"\tIngin Input Lagi[Y/T] : ";
  234. cin>>lagi;
  235. if(lagi=='Y' ||lagi=='y')
  236. goto mulai;
  237. break;
  238. }
  239.  
  240. case 3:
  241. clrscr();
  242. {
  243. cout<<endl;
  244. setcolor(12);
  245. cout<<"\tInisialisasi Array Part III"<<endl;
  246. cout<<endl;
  247. setcolor(11);
  248. for(r=0;r<5;r++)
  249. {
  250. cout<<"\tMasukkan Elemen Array ["<<(r+1)<<"] = ";cin>>q[r];
  251. }
  252. cout<<endl;
  253. cout<<"\tElemen Array Yang Telah di Input : "<<endl;
  254. for(r=0;r<5;r++)
  255. {
  256. cout<<"\tElemen Array Ke ["<<(r+1)<<"] = "<<q[r]<<endl;
  257. }
  258. cout<<endl;
  259. cout<<"\tPlease Enter To Continue...";
  260. getch();
  261. clrscr();
  262. cout<<endl;
  263. setcolor(9);
  264. cout<<"\tIngin Input Lagi[Y/T] : ";
  265. cin>>lagi;
  266. if(lagi=='Y' ||lagi=='y')
  267. goto mulai;
  268. break;
  269. }
  270.  
  271. case 4:
  272. clrscr();
  273. {
  274. cout<<endl;
  275. setcolor(12);
  276. cout<<"\tInisialisasi Array Part IV "<<endl;
  277. cout<<endl;
  278. setcolor(11);
  279. for (int t = 0; t < 7; t++)
  280. {
  281. cout<<"\tElemen Array Ke ["<<(t+1)<<"] = "<<tugas[t]<<endl;
  282. }
  283. cout<<endl;
  284. setcolor(10);
  285. cout<<"\tMasukkan Indeks Yang Akan di Ganti : ";
  286. cin>>indeks;
  287. cout<<"\tMasukan Nilai Yang Akan di Ganti : ";
  288. cin>>x;
  289. tugas[indeks]=x;
  290. cout<<endl;
  291. setcolor(12);
  292. cout<<"\tNilai Array Yang Baru : "<<endl;
  293. cout<<endl;
  294. setcolor(11);
  295. for (int t = 0; t < 7; t++)
  296. {
  297. cout<<"\tElemen Array Ke ["<<(t+1)<<"] = "<<tugas[t]<<endl;
  298. }
  299. cout<<endl;
  300. cout<<"\tPlease Enter To Continue...";
  301. getch();
  302. clrscr();
  303. cout<<endl;
  304. setcolor(9);
  305. cout<<"\tIngin Input Lagi[Y/T] : ";
  306. cin>>lagi;
  307. if(lagi=='Y' ||lagi=='y')
  308. goto mulai;
  309. break;
  310. }
  311.  
  312. case 5:
  313. clrscr();
  314. {
  315. cout<<endl;
  316. setcolor(11);
  317. char a[]={"\tTHANKYOU FOR YOUR ATTENTION\n"};
  318. char b[]={"\t\tGOOD BYE\n"};
  319. int i;
  320. double j;
  321. for(i=0;a[i]!='\0';i++){
  322. printf("%c",a[i]);
  323. for(j=0;j<=19999999;j++){
  324. }
  325. }
  326. for(i=0;b[i]!='\0';i++){
  327. printf("%c",b[i]);
  328. for(j=0;j<=19999999;j++){
  329. }
  330. }
  331. cout<<endl;
  332. cout<<endl;
  333. cout<<"\tPlease Enter To Continue...";
  334. break;
  335. }
  336.  
  337. default:
  338. clrscr();
  339. {
  340. cout<<endl;
  341. setcolor(11);
  342. cout<<"\tMenu Tidak Tersedia Harap Pilih Yang Benar !!!";
  343. getch();
  344. goto mulai;
  345. }
  346.  
  347. }
  348.  
  349. getch();
  350. return 0;
  351. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement