Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \\ Array
- #include<iostream>
- int main(){
- int size = 0, max = -2147483648;
- int *pSize = &size, *pMax = &max;
- std::cout << "Enter how much values do you want: " << std::endl;
- std::cin >> *pSize;
- int array [size];
- for(int i = 0; i < *(pSize); ++i){
- std::cout << "Enter " << i+1 << " number: ";
- std::cin >> *(&array[0]+i);
- std::cout << std::endl;
- if (*(&array[0]+i) > max)
- *pMax = *(&array[0]+i);
- }
- std::cout << " Your max value = " << *pMax;
- }
- \\one int
- #include<iostream>
- int main(){
- int size = 0, max = -2147483648, value = 0;
- int *ptrSize = &size, *ptrMax = &max, *ptrValue = &value;
- std::cout << "Enter how much values do you want: " << std::endl;
- std::cin >> *ptrSize;
- for(int i = 0; i < *(ptrSize); ++i){
- std::cout << "Enter " << i+1 << " number: ";
- std::cin >> *ptrValue;
- std::cout << std::endl;
- if ( *ptrValue > max)
- *ptrMax = *ptrValue;
- }
- std::cout << " Your max value = " << *ptrMax;
- }
Add Comment
Please, Sign In to add comment